public class TwitterAdsClient extends TwitterImpl implements OAuthSupport
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
ADS_API_URL |
protected Authorization |
auth |
protected Configuration |
conf |
protected z_T4JInternalFactory |
factory |
static com.google.gson.Gson |
GSON_INSTANCE |
protected HttpClientWrapper |
http |
protected long |
id |
protected java.lang.String |
screenName |
APPEND, COMMAND, FINALIZE, INIT, MEDIA, MEDIA_CATEGORY, MEDIA_ID, MEDIA_TYPE, PARAM_ADDITIONAL_OWNERS, SEGMENT_INDEX, STATUS, TOTAL_BYTES| Constructor and Description |
|---|
TwitterAdsClient(Configuration conf,
Authorization auth) |
| Modifier and Type | Method and Description |
|---|---|
void |
addRateLimitStatusListener(RateLimitStatusListener listener)
Registers a RateLimitStatusListener for account associated rate limits
|
Media |
checkVideoUploadStatus(java.lang.String url,
HttpParameter[] parameters) |
<T> BaseAdsListResponseIterable<T> |
constructBaseAdsListResponse(java.lang.String baseUrl,
HttpResponse httpResponse,
java.util.List<HttpParameter> params,
java.lang.reflect.Type type,
boolean isCostBasedRateLimit) |
java.lang.String |
createVideo(java.lang.String tonVideoLocation,
java.lang.String title,
java.lang.String description) |
java.lang.String |
createVideoImage(java.lang.String tonImageLocation,
java.lang.String title,
java.lang.String description) |
VideoTweetResponse |
createVideoTweet(VideoTweetRequest request) |
protected HttpResponse |
delete(java.lang.String url) |
protected HttpResponse |
delete(java.lang.String url,
HttpParameter[] params) |
protected void |
ensureAuthorizationEnabled() |
protected void |
ensureOAuthEnabled() |
boolean |
equals(java.lang.Object o) |
<T> BaseAdsListResponseIterable<T> |
executeHttpListRequest(java.lang.String baseUrl,
java.util.List<HttpParameter> params,
java.lang.reflect.Type type) |
<T> BaseAdsListResponseIterable<T> |
executeHttpListRequest(java.lang.String baseUrl,
java.util.List<HttpParameter> params,
java.lang.reflect.Type type,
boolean isCostBasedRateLimit) |
<T> BaseAdsResponse<T> |
executeHttpRequest(java.lang.String baseUrl,
HttpParameter[] params,
java.lang.reflect.Type type,
HttpVerb httpVerb) |
TwitterTonUploadResponse |
executeHttpRequestForTon(java.lang.String baseUrl,
HttpParameter[] params,
HttpVerb httpVerb,
java.util.Map<java.lang.String,java.lang.String> customHeaders) |
protected HttpResponse |
executeRequest(java.lang.String url,
HttpParameter[] params,
HttpVerb httpVerb) |
<T> T |
executeRequest(java.lang.String baseUrl,
HttpParameter[] params,
java.lang.reflect.Type typeToken,
HttpVerb httpVerb) |
protected HttpResponse |
executeRequest(java.lang.String url,
HttpVerb httpVerb) |
protected User |
fillInIDAndScreenName() |
HttpResponse |
get(java.lang.String url) |
HttpResponse |
get(java.lang.String url,
HttpParameter... params) |
Authorization |
getAuthorization()
Returns the authorization scheme for this instance.
The returned type will be either of BasicAuthorization, OAuthAuthorization, or NullAuthorization |
java.lang.String |
getBaseAdsAPIUrl() |
Configuration |
getConf() |
Configuration |
getConfiguration()
Returns the configuration associated with this instance
|
long |
getId()
Returns authenticating user's user id.
This method may internally call verifyCredentials() on the first invocation if - this instance is authenticated by Basic and email address is supplied instead of screen name, or - this instance is authenticated by OAuth. |
static TwitterAdsClient |
getInstance(Configuration conf,
Authorization auth) |
java.lang.String |
getMediaUploadBaseUrl() |
AccessToken |
getOAuthAccessToken()
Returns an access token associated with this instance.
If no access token is associated with this instance, this will retrieve a new access token. |
AccessToken |
getOAuthAccessToken(RequestToken requestToken)
Retrieves an access token associated with the supplied request token and sets userId.
|
AccessToken |
getOAuthAccessToken(RequestToken requestToken,
java.lang.String oauthVerifier)
Retrieves an access token associated with the supplied request token and sets userId.
|
AccessToken |
getOAuthAccessToken(java.lang.String oauthVerifier)
Retrieves an access token.
|
AccessToken |
getOAuthAccessToken(java.lang.String screenName,
java.lang.String password)
Retrieves an access token associated with the supplied screen name and password using xAuth.
In order to get access acquire AccessToken using xAuth, you must apply by sending an email to api@twitter.com - all other applications will receive an HTTP 401 error. |
RequestToken |
getOAuthRequestToken()
Retrieves a request token
|
RequestToken |
getOAuthRequestToken(java.lang.String callbackUrl)
Retrieves a request token
|
RequestToken |
getOAuthRequestToken(java.lang.String callbackUrl,
java.lang.String xAuthAccessType)
Retrieves a request token
|
HttpResponse |
getRequest(java.lang.String url) |
HttpResponse |
getRequest(java.lang.String url,
HttpParameter[] params) |
java.lang.String |
getScreenName()
Returns authenticating user's screen name.
This method may internally call verifyCredentials() on the first invocation if - this instance is authenticated by Basic and email address is supplied instead of screen name, or - this instance is authenticated by OAuth. Note that this method returns a transiently cached (will be lost upon serialization) screen name while it is possible to change a user's screen name. |
HttpResponse |
getWithoutMergeOfParams(java.lang.String url,
HttpParameter[] params) |
protected HttpResponse |
getWithoutMergingImplicitParams(java.lang.String url,
HttpParameter[] params) |
int |
hashCode() |
void |
httpResponseReceived(HttpResponseEvent event) |
Media |
mediaUploadInitOrFinalize(java.lang.String url,
HttpParameter[] parameters) |
protected HttpParameter[] |
mergeImplicitParams(HttpParameter[] params) |
protected HttpParameter[] |
mergeParameters(HttpParameter[] params1,
HttpParameter params2) |
protected HttpParameter[] |
mergeParameters(HttpParameter[] params1,
HttpParameter[] params2) |
protected HttpResponse |
post(java.lang.String url) |
HttpResponse |
post(java.lang.String url,
HttpParameter... params) |
protected HttpResponse |
post(java.lang.String url,
java.lang.String requestBody) |
HttpResponse |
postBatchRequest(java.lang.String url,
java.lang.String requestBody) |
HttpResponse |
postRequest(java.lang.String url,
HttpParameter[] params) |
HttpResponse |
postRequest(java.lang.String url,
java.lang.String requestBody) |
protected HttpResponse |
postWithCustomHeaders(java.lang.String url,
HttpParameter[] params,
java.util.Map<java.lang.String,java.lang.String> customHeaders,
boolean isTonUpload) |
protected HttpResponse |
put(java.lang.String url) |
protected HttpResponse |
put(java.lang.String url,
HttpParameter[] params) |
HttpResponse |
putRequest(java.lang.String url,
HttpParameter[] params) |
protected HttpResponse |
putWithCustomHeaders(java.lang.String url,
HttpParameter[] params,
java.util.Map<java.lang.String,java.lang.String> customHeaders,
boolean isTonUpload) |
protected void |
setFactory() |
void |
setOAuthAccessToken(AccessToken accessToken)
Sets the access token
|
void |
setOAuthConsumer(java.lang.String consumerKey,
java.lang.String consumerSecret)
sets the OAuth consumer key and consumer secret
|
void |
shutdown()
Shuts down this instance and releases allocated resources.
|
Media |
upload(MediaUpload mediaUpload) |
java.lang.String |
uploadToTon(TonUpload tonUpload) |
TwitterLibraryMedia |
waitForMediaProcessing(java.lang.String accountId,
java.lang.String mediaKey,
long maxWaitTime) |
createBlock, createBlock, destroyBlock, destroyBlock, destroyStatus, getAccountSettings, getBlocksList, getBlocksList, getContributees, getContributees, getContributors, getContributors, getRelatedResults, getRetweets, getRetweetsOfMe, getRetweetsOfMe, getScopedTimeLine, lookupStatuses, lookupUsers, lookupUsers, removeProfileBanner, retweetStatus, searchUsers, showStatus, showUser, showUser, toString, updateAccountSettings, updateProfile, updateProfileBackgroundImage, updateProfileBackgroundImage, updateProfileBanner, updateProfileBanner, updateProfileColors, updateProfileImage, updateProfileImage, updateStatus, updateStatus, uploadMediaInChunks, verifyCredentials, waitForVideoTranscodingclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetOAuthAccessToken, getOAuthAccessToken, getOAuthAccessToken, getOAuthAccessToken, getOAuthAccessToken, getOAuthRequestToken, getOAuthRequestToken, getOAuthRequestToken, setOAuthAccessToken, setOAuthConsumeraddRateLimitStatusListener, getAuthorization, getConfiguration, getId, getScreenName, shutdowncreateVideo, createVideoImage, createVideoTweet, upload, uploadToTonpublic static final java.lang.String ADS_API_URL
public static final com.google.gson.Gson GSON_INSTANCE
protected Configuration conf
protected transient java.lang.String screenName
protected transient long id
protected transient HttpClientWrapper http
protected z_T4JInternalFactory factory
protected Authorization auth
public TwitterAdsClient(Configuration conf, Authorization auth)
public static TwitterAdsClient getInstance(Configuration conf, Authorization auth)
public java.lang.String getBaseAdsAPIUrl()
public java.lang.String getMediaUploadBaseUrl()
public <T> BaseAdsListResponseIterable<T> executeHttpListRequest(java.lang.String baseUrl, java.util.List<HttpParameter> params, java.lang.reflect.Type type) throws TwitterException
TwitterExceptionpublic <T> BaseAdsListResponseIterable<T> executeHttpListRequest(java.lang.String baseUrl, java.util.List<HttpParameter> params, java.lang.reflect.Type type, boolean isCostBasedRateLimit) throws TwitterException
TwitterExceptionpublic <T> BaseAdsListResponseIterable<T> constructBaseAdsListResponse(java.lang.String baseUrl, HttpResponse httpResponse, java.util.List<HttpParameter> params, java.lang.reflect.Type type, boolean isCostBasedRateLimit) throws TwitterException, java.io.IOException
TwitterExceptionjava.io.IOExceptionpublic <T> BaseAdsResponse<T> executeHttpRequest(java.lang.String baseUrl, HttpParameter[] params, java.lang.reflect.Type type, HttpVerb httpVerb) throws TwitterException
TwitterExceptionpublic HttpResponse postRequest(java.lang.String url, java.lang.String requestBody) throws TwitterException
TwitterExceptionpublic HttpResponse postRequest(java.lang.String url, HttpParameter[] params) throws TwitterException
TwitterExceptionpublic HttpResponse getRequest(java.lang.String url, HttpParameter[] params) throws TwitterException
TwitterExceptionpublic HttpResponse getRequest(java.lang.String url) throws TwitterException
TwitterExceptionpublic HttpResponse getWithoutMergeOfParams(java.lang.String url, HttpParameter[] params) throws TwitterException
TwitterExceptionpublic HttpResponse putRequest(java.lang.String url, HttpParameter[] params) throws TwitterException
TwitterExceptionpublic TwitterTonUploadResponse executeHttpRequestForTon(java.lang.String baseUrl, HttpParameter[] params, HttpVerb httpVerb, java.util.Map<java.lang.String,java.lang.String> customHeaders) throws TwitterException
TwitterExceptionpublic <T> T executeRequest(java.lang.String baseUrl,
HttpParameter[] params,
java.lang.reflect.Type typeToken,
HttpVerb httpVerb)
throws TwitterException
TwitterExceptionpublic TwitterLibraryMedia waitForMediaProcessing(java.lang.String accountId, java.lang.String mediaKey, long maxWaitTime) throws TwitterException
TwitterExceptionpublic Configuration getConf()
public HttpResponse get(java.lang.String url) throws TwitterException
TwitterExceptionpublic HttpResponse get(java.lang.String url, HttpParameter... params) throws TwitterException
TwitterExceptionpublic HttpResponse post(java.lang.String url, HttpParameter... params) throws TwitterException
TwitterExceptionprotected HttpResponse put(java.lang.String url, HttpParameter[] params) throws TwitterException
TwitterExceptionprotected HttpResponse delete(java.lang.String url) throws TwitterException
TwitterExceptionprotected HttpResponse delete(java.lang.String url, HttpParameter[] params) throws TwitterException
TwitterExceptionprotected HttpResponse getWithoutMergingImplicitParams(java.lang.String url, HttpParameter[] params) throws TwitterException
TwitterExceptionprotected void setFactory()
public java.lang.String getScreenName()
throws TwitterException,
java.lang.IllegalStateException
getScreenName in interface TwitterBaseTwitterException - when verifyCredentials threw an exception.java.lang.IllegalStateException - if no credentials are supplied. i.e.) this is an anonymous Twitter instancepublic long getId()
throws TwitterException,
java.lang.IllegalStateException
getId in interface TwitterBaseTwitterException - when verifyCredentials threw an exception.java.lang.IllegalStateException - if no credentials are supplied. i.e.) this is an anonymous Twitter instanceprotected User fillInIDAndScreenName() throws TwitterException
TwitterExceptionpublic void addRateLimitStatusListener(RateLimitStatusListener listener)
addRateLimitStatusListener in interface TwitterBaselistener - the listener to be addedpublic void httpResponseReceived(HttpResponseEvent event)
httpResponseReceived in interface HttpResponseListenerpublic final Authorization getAuthorization()
getAuthorization in interface TwitterBasepublic Configuration getConfiguration()
getConfiguration in interface TwitterBasepublic void shutdown()
shutdown in interface TwitterBaseprotected final void ensureAuthorizationEnabled()
protected final void ensureOAuthEnabled()
public void setOAuthConsumer(java.lang.String consumerKey,
java.lang.String consumerSecret)
setOAuthConsumer in interface OAuthSupportconsumerKey - OAuth consumer keyconsumerSecret - OAuth consumer secretpublic RequestToken getOAuthRequestToken() throws TwitterException
getOAuthRequestToken in interface OAuthSupportTwitterException - when Twitter service or network is unavailablepublic RequestToken getOAuthRequestToken(java.lang.String callbackUrl) throws TwitterException
getOAuthRequestToken in interface OAuthSupportcallbackUrl - callback URLTwitterException - when Twitter service or network is unavailablepublic RequestToken getOAuthRequestToken(java.lang.String callbackUrl, java.lang.String xAuthAccessType) throws TwitterException
getOAuthRequestToken in interface OAuthSupportcallbackUrl - callback URLxAuthAccessType - Overrides the access level an application requests to a users account. Supported values are read or write. This parameter is intended to allow a developer to register a read/write application but also request read only access when appropriate.TwitterException - when Twitter service or network is unavailablepublic AccessToken getOAuthAccessToken() throws TwitterException
getOAuthAccessToken in interface OAuthSupportTwitterException - When Twitter service or network is unavailable, when the user has not authorized, or when the client application is not permitted to use xAuthpublic AccessToken getOAuthAccessToken(java.lang.String oauthVerifier) throws TwitterException
getOAuthAccessToken in interface OAuthSupportoauthVerifier - OAuth verifier. AKA pin.java.lang.IllegalStateException - when AccessToken has already been retrieved or setTwitterException - when Twitter service or network is unavailable, or the user has not authorizedpublic AccessToken getOAuthAccessToken(RequestToken requestToken) throws TwitterException
getOAuthAccessToken in interface OAuthSupportrequestToken - the request tokenjava.lang.IllegalStateException - when AccessToken has already been retrieved or setTwitterException - when Twitter service or network is unavailable, or the user has not authorizedpublic AccessToken getOAuthAccessToken(RequestToken requestToken, java.lang.String oauthVerifier) throws TwitterException
getOAuthAccessToken in interface OAuthSupportrequestToken - the request tokenoauthVerifier - OAuth verifier. AKA pin.java.lang.IllegalStateException - when AccessToken has already been retrieved or setTwitterException - when Twitter service or network is unavailable, or the user has not authorizedpublic void setOAuthAccessToken(AccessToken accessToken)
setOAuthAccessToken in interface OAuthSupportaccessToken - accessTokenpublic AccessToken getOAuthAccessToken(java.lang.String screenName, java.lang.String password) throws TwitterException
getOAuthAccessToken in interface OAuthSupportscreenName - the screen namepassword - the passwordTwitterException - when Twitter service or network is unavailable, or the user has not authorizedpublic Media upload(MediaUpload mediaUpload) throws TwitterException
TwitterExceptionpublic Media mediaUploadInitOrFinalize(java.lang.String url, HttpParameter[] parameters) throws TwitterException
TwitterExceptionpublic Media checkVideoUploadStatus(java.lang.String url, HttpParameter[] parameters) throws TwitterException
TwitterExceptionpublic java.lang.String createVideo(java.lang.String tonVideoLocation,
java.lang.String title,
java.lang.String description)
throws TwitterException
TwitterExceptionpublic java.lang.String createVideoImage(java.lang.String tonImageLocation,
java.lang.String title,
java.lang.String description)
throws TwitterException
TwitterExceptionpublic VideoTweetResponse createVideoTweet(VideoTweetRequest request) throws TwitterException
TwitterExceptionpublic java.lang.String uploadToTon(TonUpload tonUpload) throws TwitterException
TwitterExceptionpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectprotected HttpResponse executeRequest(java.lang.String url, HttpVerb httpVerb) throws TwitterException
TwitterExceptionprotected HttpResponse executeRequest(java.lang.String url, HttpParameter[] params, HttpVerb httpVerb) throws TwitterException
TwitterExceptionprotected HttpResponse post(java.lang.String url) throws TwitterException
TwitterExceptionprotected HttpResponse post(java.lang.String url, java.lang.String requestBody) throws TwitterException
TwitterExceptionprotected HttpResponse postWithCustomHeaders(java.lang.String url, HttpParameter[] params, java.util.Map<java.lang.String,java.lang.String> customHeaders, boolean isTonUpload) throws TwitterException
TwitterExceptionprotected HttpResponse putWithCustomHeaders(java.lang.String url, HttpParameter[] params, java.util.Map<java.lang.String,java.lang.String> customHeaders, boolean isTonUpload) throws TwitterException
TwitterExceptionprotected HttpResponse put(java.lang.String url) throws TwitterException
TwitterExceptionpublic HttpResponse postBatchRequest(java.lang.String url, java.lang.String requestBody) throws TwitterException
TwitterExceptionprotected HttpParameter[] mergeParameters(HttpParameter[] params1, HttpParameter[] params2)
protected HttpParameter[] mergeParameters(HttpParameter[] params1, HttpParameter params2)
protected HttpParameter[] mergeImplicitParams(HttpParameter[] params)