I am having some problems working around with Scribe java library for Twitter. I succeeded in logging in twitter using the library and collecting the user profile data, but can't seem to figure out how to post tweets on behalf of the user.
I looked at the example from the github page but it was only for accessing data, not posting.
This is a method I came up with, after doing some research,
what should I pass on the URL
, if I was reading data then url="https://api.twitter.com/1.1/account/verify_credentials.json"
would have been valid. But since I am trying to post a tweet. What should I do??
def request(verb: Verb, url: String, accessToken: org.scribe.model.Token, reqBody: String, d: String): String = {
val request: OAuthRequest = new OAuthRequest(verb, url)
request.addBodyParameter("status", reqBody)
service(d).signRequest(accessToken, request)
val response: Response = request.send
response.getBody
}
The service method, for connection
def service(url: String): OAuthService = new ServiceBuilder()
.provider(classOf[TwitterApi.Authenticate])
.apiKey("XXXXX")
.apiSecret("XXXXX")
.callback(url)
.build
Can someone, provide me with some ideas and pointers.
Thank you,
@update: It seems, for posting status , url=https://api.twitter.com/1.1/statuses/update.json?status=helllllooooo
is the required URL
,thanks to this SO post , seems to do the trick,
So,If for additional features:
#hash1
in the message body
enough, or there are special way to do so??I have been researching for the answers myself as well, hope you could provide me with some insights as well,
I think the pieces of documentation you need are the POST statuses/update page:
https://dev.twitter.com/docs/api/1.1/post/statuses/update
and this specific FAQ about link wrappers...
In summary, hashtags and URLs/shortening with look after themselves - you just need to make sure you URL encode as appropriate.
You share a link with an image the same way you share any other URL (you just include it in the URL-encoded string that's POSTed). An image will show up if the underlying site is setup/the target URL is tagged to present a Twitter cards, as described here: