Twitter provided a great 1.0 API. I could grab an user image just like this:
http://api.twitter.com/1/users/profile_image/twitter
Does the 1.1 update give anything like this away for free? Or does the 1.1 update require authentication for a user image and user name? I noticed there is no equivalent call in the docs.
and this does not work:
http://api.twitter.com/1.1/users/profile_image/twitter
You can only get the user image and user name with authentication.
If you're trying to get the user profile image with Abraham's twitteroauth, then I guess this link will help you.
You can get the user name similarly by calling the name object and display it.
You should find your answers in the Twitter API docs here:
https://dev.twitter.com/docs/user-profile-images-and-banners
e.g: https://api.twitter.com/1.1/users/show.json?screen_name=twitterapi
and it does requires Authentication to retrieve it:
Related
The API documented here - http://developer.yammer.com/restapi/#rest-users clearly states:
"4) Alias to /api/v1/users/current user’s id.format. Supports include_followed_users, include_followed_tags, and include_group_memberships parameters.
GET https://www.yammer.com/api/v1/users/by_email.json?email=user#domain.com`
Yet, when we try this, it does not return any followed user information at all! The request we're using is like so:
https://www.yammer.com/api/v1/users/by_email.json?email=me#company.com&include_followed_users=true
However, this request DOES return followed users, but only for the current user:
https://www.yammer.com/api/v1/users/current.json?include_followed_users=true
Am I missing something completely obvious and being stupid or is there a real issue here? If this was taken out for whatever reason, then you'd have thought that the API documentation would have been updated.
The Yammer Team did eventually get back to me on this. Their response below:
(I've removed https://www.yammer.com from URLs because I don't have enough rep' to post more links)
Hey Jason Dunbar looks like the documentation here is wrong.
I looked in to this and had some conversations with a few engineers this week and have the following (albeit more arduous workaround):
1) Call get user by email endpoint and retrieve the id attribute from here: /api/v1/users/by_email.json?email=user…
2) To grab following users, take that id and:
GET /api/v1/users/following/[:id].json
3) To grab group memberships for that user you'll need to impersonate him/her (verified admin only) and
GET /api/v1/users/current.json
We'll get the documentation updated ASAP with this. Also happy to keep the conversation going to help if needed.
Make sure you are setting the email parameter to the user's email that they are registered with.
E.G. if your company has multiple domains but the Yammer network is under bigco.com and the user is registered with an email under bigcosubsidiary.com you'll need to make a request to the API with user#bigcosubsidiary.com.
-as mentioned - it looks like its only for current.json - you can check it here http://yammer-dev.herokuapp.com/endpoints/4 - hope it helps.
Rich
The "old" Facebook Graph API had a "username" field which could be used to create a human-readable profile URL. My username for example is "sebastian.trug" which results in a Facebook profile URL http://www.facebook.com/sebastian.trug.
With Graph API 2.0 Facebook has removed the "username" field from the user data as retrieved from "/me".
Is there any way to get this data via the 2.0 API or is the "username" now being treated as a deprecated field?
Facebook got rid of the username because the username is one way of sending emails via Facebook.
For example, given the url http://www.facebook.com/sebastian.trug
the corresponding Facebook email would be sebastian.trug#facebook.com
which, if emailed, would be received to messages directly (if the message setting is set to public), otherwise to the other inbox.
The username field of the User object has been removed, and does not exist in Graph API v2.0. In v2.0 of the API is there is no way to get the FB username of a user.
Source: https://developers.facebook.com/docs/apps/changelog#v2_0_graph_api
"/me/username is no longer available."
#Simon Cross - It being deprecated is documented, yes. That is not the question, the question is how to get it and -furthermore- I wonder why Facebook has made such a terrible choice and removed the username. Hundreds of applications that rely on the username to create accounts on their service will be broken.
#user3596238 - You can stick with the V.1 API which will be around until the end of April 2015, by far not the best solution but Facebook might be irrelevant by then anyway.
https://developers.facebook.com/docs/apps/changelog
Solution: ask the user for a username besides the actual Facebook login? - In my opinion, that makes the Facebook login completely pointless anyway.
While the 2.0 SDK will not provide the username field any longer, it is quite easily scraped if you have the user id number (which you will likely be using to access the graph anyway).
The url facebook.com/<user id> will redirect to facebook.com/<username>, which can then be extracted however you like.
my approach is scrapping the username using nokogiri through the user profile.
kinda like this (in ruby):
html = RestClient.get("http://facebook.com/123123xxx)
doc = Nokogiri::HTML(html)
username = doc.css('head meta')[1].attributes["content"].value
One of the ways could be to access facebook.com/{userid} using cURL and then follow the redirect.
The page rediects to facebook.com/{username}
Inspired from #RifkiFauzi 's answer, here is my solution in pure Python
#get html of a page via pure python ref. https://stackoverflow.com/a/23565355/248616
import requests
r = requests.get('http://fb.com/%s' % FB_USER_ID) #open profile page of the facebook user
r.raise_for_status()
html = r.content
#search string with regex ref. https://stackoverflow.com/a/4667014/248616
import re
# m = re.search('meta http-equiv="refresh" content="0; URL=/([^?]+)\?', html)
m = re.search('a class="profileLink" href="([^"]+)"', html)
href = m.group(1) #will be https://www.facebook.com/$FB_USER_NAME on 201705.24
username = href.split('/')[-1]
print(href)
print(username)
https://graph.facebook.com/?id=100005908663675
Simply change id to whatever.
I found a good tutorial for building Facebook membership Authentication website which demo file is here > http://niftyandcrackerjack.com/sites/default/files/Test.zip
I wonder this example does not use access token to retrieve Facebook User Info. It use classes inherits from the masterpage. As I am new to ASP.NET, I don't know how to retrieve Facebook user info. Can someone give me and suggestion or explain...... Thanks,
My finding so far indicate that basic information cannot be accessed unless one has either 'userid' or 'username' as in this post.
If one has to try and fetch basic information using following url, then access_token is needed
http://graph.facebook.com/me
Perform an HTTP GET to https://graph.facebook.com/{userid} or HTTP GET to https://graph.facebook.com/{username}
Examples: Click the link below to see the JSON response.
https://graph.facebook.com/4
https://graph.facebook.com/zuck
Pretty cool, eh? And no token needed to get at this public info.
You can get more info on this here: https://developers.facebook.com/docs/reference/api
I am using Graph API in my application. I am fetching user's facebook wall feeds using graph API also getting details of particular post i.e (Like count,Comments etc).
but i want to allow user to Like and Comment any post from the application itself.
what is the request format for that?
Please help me or give any pointers.
Regards,
Sanket
You would be well served to check out the Publishing section of the documentation. It provides information such as this.
One example is liking, which is defined as:
Method: /OBJECT_ID/likes
Description: Like the given object (if it has a /likes connection)
Arguments: none
Basically, just initiate a Graph API call to something like:
[facebookObject requestWithGraphPath:#"98423808305/likes" andDelegate:self];
That will "like" a picture from Coca-Cola (ID taken from the documentation).
Edit 1
According to the documentation:
Most write operations require extended permissions for the active user. See the authentication guide for details on how you can request extended permissions from the user during the authentication step.
Are you sure you have enough privileges? Unfortunately the documentation is very unclear as to whether it serves the dual purpose of liking the object and returning the likes already on that object.
Edit 2
I did some more research into what could be causing this and came across this question and answer that indicated that the code I posted above using requestWithGraphPath:: should work. However, it does not due to a bug on Facebook's Bug Tracker.
Unfortunately, it looks like there is no way to "like" an object via the Graph API, which seems very strange to me. Perhaps it is possible with the legacy REST API instead of the Graph API?
Edit 3
Well, it looks like your best bet is the stream.addLike method of the legacy REST API which you can still call using the Facebook iOS SDK. You should be able to use the stream.addLike method to "like" something in the "stream". Unfortunately, it doesn't appear to support photos, videos, etc. Only posts and comments.
Finally i found the solution for LIKE option
We should use following method for like option.
-(void) requestWithGraphPath:(NSString *)graphPath
andParams:(NSMutableDictionary *)params
andHttpMethod:(NSString *)httpMethod
andDelegate:(id <FBRequestDelegate>)delegate
graphPath = /OBJECT_ID/likes
Paramas = dictionary with comment ,for like option use empty dictionary
HttpMethod should be POST
you should get response = true if the LIKE request is successful.
Does Facebook provide a URL the user can access that will take him to his profile page with the "What's on your mind" box auto completed with a value provided in the URL? I need something like "http://facebook.com?status=This is my new status message".
Use FB.Connect.streamPublish, like so:
FB.Connect.streamPublish("I just visited dandu's website!");
Of course, this means creating an application and loading the Facebook Connect JS libraries in your website, check their docs for how to do that (setting up can be a daunting task). The advantage of doing so is that you don't need extended permissions. However, the user will be prompted and will have the choice of not updating their status through your app.
AFAIK, there's no simple URL to set a user's status (like twitter has), just the "sharer.php", which doesn't take a status message.
It appears you'll have to authenticate as described on the REST api documentation for status.set: http://wiki.developers.facebook.com/index.php/Status.set
I couldn't find another option, and since they require you to authenticate for that method, it is reasonable to assume they'll require you to authenticate for any api that lets you update the status.
I was looking for something similar.
This seems to detail what you are looking for:
http://developers.facebook.com/docs/reference/dialogs/feed/
Try This for Facebook status update URL:
url = "https://graph.facebook.com/me/feed?access_token=" + oAuth.Token;
json = oAuth.WebRequest(oAuthFacebook.Method.POST, url, "message=" + msg);