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:
How to post hashtags, Is appending #hash1 in the message body
enough, or there are special way to do so??
And how do we post links, like any normal links, appends the links in
message??
And how can we share links, with images??
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...
https://dev.twitter.com/docs/tco-link-wrapper/faq#When_are_links_wrapped_with_t.co_Do_I_need_to_make_an_extra_API_call
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:
https://dev.twitter.com/docs/cards
Related
I am new to tweeter api(beginner level experience), have been exploring tweeter rest api. so far I managed to read user timeline, followers count and also able to tweet.
However in a tweet, I wish to mention users by using "#" symbol.
example something like this.
This is not working, also the same case with hashtags "#"
getting error as
If I remove "#", then it works and posts a message.
Also referred the reference api https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-statuses-update
However neither could i figure out any relevant parameter that I can use nor able to find any example while surfing.
For this POC, Twitter standard api is used(Just thinking if this feature is allowed in standard api)
Thanks and appreciate any advice/guidance
Ashish
This is because of the way that Postman is encoding your request, which breaks OAuth 1.0A for Twitter. You can try the following:
Disable all params in Params tab
Open Body tab and click x-www-form-urlencoded, then add params as needed
I'm working in a React-Native app, and I'm also allowing users to login using FBSDK.
There seems to be an issue at the moment when trying to get the profile picture URL.
There are also several reports of this, like this one but still, after a year doesn't seem to be solved.
Attempted many ways but none worked, it always tries to download the file, seems it's missing the mime-type according to what the browser says.
The URL it gives is the following:
https://platform-lookaside.fbsbx.com/platform/profilepic/?asid={{myfbid}}&height=50&width=50&ext=1583348357&hash=AeTnFpMVwBXgFy_J
Also tried using the graph url directly: http://graph.facebook.com/{myid}/picture
And if I add the &redirect=false, it returns a data object with the platform-lookaside URL.
Everything I try, it tries to download.
This is how I'm currently trying to get the image using Graph API.
new GraphRequestManager().addRequest(new GraphRequest(
'/me',
{
accessToken: fbToken,
parameters: {
fields: {
string: 'picture.type(large)'
}
}
},
graphRequestCallback
)).start();
It works, but the URL is the same.
Any idea on how can I solve this? I might be missing something or the bug is still happening?
If you just change the graph url (http://graph.facebook.com/{myid}/picture) from http to https, it should work for you. Not sure if that's a new fix in React Native or not, but that solved it for me.
I'm using the Facebook Graph API, Mobile hosting API to post a link with the following:
https://graph.facebook.com/{APPID}/app_link_hosts?access_token={ACCESS_TOKEN}&name=Puzzle_1420352145684&ios=[{"url":"MyAPP://playerPuzzles/1420352145684","app_store_id":{MYAPPID},"app_name":"MyAPP"}]&web={"should_fallback":false}
I get the correct result in the form of the ID of the link, with no error.
But when I query the link with
https://graph.facebook.com?ids={LINK}&access_token={ACCESS_TOKEN};
I don't get any app-link data the object is there but empty not even the name.
{"http://fb.me/777314042342441" = {
id = "http://fb.me/777314042342441";
};
}
Is there something wrong in my posting that doesn't allow the data to get posted?
Thanks for you help in advance.
It seems that the facebook documenatation is wrong. I finally found a solution using the graph explorer.
To correctly fetch the data use this style of URL.
https://graph.facebook.com/{APP-LINK-ID}?fields=ios,name,web&access_token={ACCESS_TOKEN};
Please note that you have to call out all the fields you want. The object at least for me didn't include the app_links structure like the documentation.
Here is the link to the wrong Index API
Here is the app_links object structure you can see all the fields you can fetch.
Hope this helps everyone.
I'm using tornado web server and to integrate linkedin in my application I'm using the LinkedinMixin class that I add to the framework from an unofficial code in github. All is working perfectly, but I would like to be able to use the share api
POST
http://api.linkedin.com/v1/people/~/shares
The linkedin API is in XML, this is the reason why it's sometimes difficult to integrate it in tornado
https://developer.linkedin.com/documents/api-requests-json
I found this article which tell me to send
{
"contentType":"linkedin-html",
"body":"My Fancy Update"
}
to post an update but it sends me a HTTP 401: Unauthorized fetching http://api.linkedin.com/v1/people/~/shares?...
I would like to know if someone knows another version of linkedinMixin that this one :
https://github.com/facebook/tornado/pull/236/files
And if someone could give me a complete example of share API using JSON
Thanks,
I should probably point out that I have no experience with the LinkedIn API or the Tornado webserver. I have done a lot of work with OAuth, JSON and XML though.
Judging by the class you mentioned, the
def linkedin_request(self, path, callback, access_token=None, post_args=None, **args):
does exactly what you want. No need to bother about requesting JSON, etc. It does it for you.
I haven't really analyzed the classes, but I'd assume that your callback would look something like :
import json
def callback(data):
# If data is a JSON string, parse it. (remove this if data is a dict)
data = json.loads(data)
# Do something with the data
print data
def makeRequest():
something.linkedin_request("/v1/people/~/shares", callback)
I hope that this pointed you in the right direction :-)
I rather expect that this might be impossible - but I was wonderring if it was possible to post a facebook status via passing in a URL.
Something to the effect of
http://facebook.com/?status=<URL ENCODED STRING>
Wow. Almost a full year since I asked this question.
As an FYI and for my own future reference, I did eventually discover how to do this.
http://www.facebook.com/sharer/sharer.php?u=<url to share>&t=<message text>
https://twitter.com/intent/tweet?text=<message>
http://www.linkedin.com/shareArticle?mini=true&url=<url>&title=<title>&summary=<description>&source=<source>
Google plus does not have a good option to use this method in desktop, but you can use their mobile URL
https://m.google.com/app/plus/x/?v=compose&content=<message>
I found this solution useful also (here)
var facebook_url = 'http://www.facebook.com/sharer.php?'+
'u='+encodeURIComponent('http://google.com/?q=bla')+
'&t='+encodeURIComponent('Some Page Title');
There's a builtin CURL converter in the Graph API that gets you all you need.