I have 3 questions: 1)Can I combine facebook login via mozila browser(selenium) with facebook graph api, for example:
browser=webdriver.Firefox()
browser.get('https://facebook.com')
user=browser.find_element_by_id('email')
user.send_keys('email')
password=browser.find_element_by_id('pass')
password.send_keys('pass')
login=browser.find_element_by_id('u_0_r')
login.click()
graph = facebook.GraphAPI(token)
profile = graph.get_object("me")
friends = graph.get_connections("me", "friends")
friend_list = [friend['name'] for friend in friends['data']]
print (friend_list)
2)Can somebody help me with login on facebook through app_id, secret_id and token, or through email and password
3)I want to get profile info, for example with help of get_object, but I need to know user's id to do it. How can I get this id, if I have only page url's, or I can use part after facebook.com/ to do this request?
P.s. If u know answer at least on one of this questions, pls right it in comments or in answers, it will be very useful:)
Related
I have developed a Facebook app in test mod and I want to publish on the test user's wall.
this is the link where the user register and accept the permissions:
https://www.facebook.com/dialog/oauth?type=user_agent&client_id=MY_APP_ID&display=popup&redirect_uri=THE_URL&scope=email%2Cpublish_actions
After that I am getting an some sort of a token, using this token I am doing the following request to the graph:
/oauth/access_token?client_id=MY_APP_ID&client_secret=MY_APP_SECRET&grant_type=fb_exchange_token&fb_exchange_token=".$token
the token coming back is now being used by me to get the user's details from the graph:
/me/?$user_access_token&fields=name,age_range,id,email,gender,currency,locale,timezone"
I am getting in result all the fields listed above. (one strange thing, the id coming back is not the test user's public id, the other field are correct...)
when I want to post so someones wall I am running this int the graph:
/oauth/access_token?client_id=MY_APP_ID&client_secret=MY_SECRET&grant_type=client_credentials
the token coming back will be used here:
$token = self::getAccessToken($app_id,$app_secret);
$post_array = array();
$post_array['access_token'] = $token;
$post_array['message'] = urlencode($message);
$post_array['link'] = urlencode($link);
$res = self::post("https://graph.facebook.com/".$user_id."/feed?",$post_array);// the user id might be wrong?
and I am getting the following error:
{"error":{"message":"(#200) Permissions error","type":"OAuthException","code":200,"fbtrace_id":"EO5WvMfYYgC"}}
What can it be?
the fact that I am in test mod?
or maybe the user's ID i got back is wrong?
Thanks
The ID is correct, you only get an "App Scoped ID". You are not supposed to use the global/public ID anymore, and you should use /me/feed for posting, not /user-id/feed. You can only post on the wall of the authorized user anyway.
Has anyone seen a full example of how to pull facebook reviews using the graph api.
According to the docs:
A page access token is required to retrieve this data.
I have code that asks a user to login already and gets an auth token which I can use to post a message to their facebook feed. Is there an additional step I need to do to be able to read their reviews/ratings?
Here is an example of the code to post to their feed/page.
response = Curl.post("https://graph.facebook.com/#{page_id}/feed", {
:message => message,
:access_token => auth_token
})
Thanks
If you're referring to Page Ratings (different from App Reviews!), then the endpoint is
GET /{page_id}/ratings
as described here: https://developers.facebook.com/docs/graph-api/reference/page/ratings You'll need a Page Access Token for this.
Where I get a little bit confused is that you mention that you want to
read their reviews/ratings
In that case it's something else, because afaik it's currently not possible to query the User's Page ratings via Graph API or FQL. It's was only possible to query App Reviews via FQL (see https://developers.facebook.com/docs/reference/fql/review/) (Update: FQL is no longer available since 2016)
You need to set permission in the app to access the {GET /{page_id}/ratings} API. The permission is common for
/page/comments,
/page/posts,
/page/ratings,
/page/tagged,
and the permission name is "pages_read_user_content"
https://developers.facebook.com/docs/permissions/reference/pages_read_user_content
I've been using the great facebook OpenGraph and the publish_actions permission. My users can publish actions through our website, and it's directly connected to there Facebook-Timeline. Great integration, very simple to be developped : thanks a lot for your work!
But, I have one more question :
Is it possible to use publish_actions not from a specific user but directly from a Facebook Page? (as described here for a user: https://developers.facebook.com/docs/opengraph/actions/#create)
For example, User John Smith has one Facebook Page (named "John Smith Advocate"), and wants to publish action, not from John Smith himself, but from the Facebook Page "John Smith Advocate".
I wonder if it's possible.
Thanks a lot guys !
In order to publish as a page, you need to obtain an authentication token for that page. To do this you need to follow these steps (sorry for the lack of detail, hopefully this will point you in the right direction):
1) A user who is an administrator of your page needs to be authenticated with your app, and you need to get the "manage_pages" extended permission for them
2) get a list of all the accounts the user is an admin of:
https://graph.facebook.com/me/accounts
3) you'll get a json array of pages the user is an admin of, and also an access token for each page - extract the relevant access token
4) Use the access token to post to the relevant album ID (owned by the page) - here is some php code that does it;
<?php
$args = array('message' => 'Caption');
$args['image'] = '/path/to/image.jpg';
$args['access_token'] = $page_access_token;
$data = $facebook->api('/'. $album_id . '/photos', 'post', $args);
i little speak english
i want create feed (post, note, link) to page wall ANY TIME (like offline_access) with new graph api
What should I do for it , what permissions should
thank you in advance.
create facebook app
take appid
copy this link to browser
https://www.facebook.com/dialog/oauth?client_id=appid&redirect_uri=canvasurl&scope=manage_pages&response_type=token
provide appid and the url u given in canvas url(eg:http://localhost/web)
redirected url u can see access token.take that access token value.
Facebook_Graph_Toolkit.GraphApi.Api x = new Facebook_Graph_Toolkit.GraphApi.Api(accesstoken);
string id = x.PostFeedToTarget("pageid", "hi test");
I'm trying to figure out how to get users friends information using either Graph API or FQL
Just for testing I would like to get my friends education_histroy.
To do that I created a test app, requested extended permissions using
scope=offline_access,manage_friendlists,friends_work_history,
friends_education_history,friends_about_me
and got access token to play with the API.
It works great when I query for current user using /me. But it returns nothing for my friends.
I was assuming that if I request, let's say friends_work_history, that extra field (work_history) will appear inside friend's object, when I query by friend's id:
https://graph.facebook.com/FRIEND_ID&access_token=TOKEN
But all I see is basic info about that user (friend).
Then I tried to request that field specifically:
https://graph.facebook.com/FRIEND_ID?fields=work&access_token=TOKEN
With no luck again. Returns just friend's id..
I tried to access that information with FQL:
https://api.facebook.com/method/fql.query?query=select+work_history+from+user+where+uid+in+(FRIEND_ID)&access_token=TOKEN
Returns work_history = TRUE instead of array. And that friend definitely has work history specified.
Can someone help me to understand how to get friends info using my app and extended permissions?
Graph API is the smart choice in most cases. To retrieve your friend information you need to collect some extended permissions from the user first. Then you can retrieve a lot more information other than the basic ones.
Following is a list of extended permissions related to friends different kind of information
friends_about_me
friends_activities
friends_birthday
friends_checkins
friends_education_history
friends_events
friends_games_activity
friends_groups
friends_hometown
friends_interests
friends_likes
friends_location
friends_notes
friends_online_presence
friends_photo_video_tags
friends_photos
friends_relationship_details
friends_relationships
friends_religion_politics
friends_status
friends_subscriptions
friends_videos
friends_website
friends_work_history
Hope it helps :)
I've been wrestling with this all day myself and I believe I have figured it out, nowhere in facebook documentation (that I have found) is this clear. And I don't believe the other answers actually answered your question, it looks like you requested permissions correctly. Anyway, to request the information you are looking for, ping the api like this:
https://graph.facebook.com/userid/friends?fields=work&access_token=ACCESSTOKENHERE
This will return you all the friends' info in one long JSON response.
It is a little confusing because the permissions you are asking for are not the same thing you need to query the API.
The query above will return the friends' ids with work history. You can add commas to the fields parameter to include additional info like name, but then the API calls/responses end up taking a long time.
http://developers.facebook.com/docs/reference/api/user/
you can get all the fields mentioned here .To get work you need to have user_work_history or friends_work_history permission
in the link it is mentioned what permissions to obtain before you get the info and another thing that user has to allow your application,this will make your app to get the informations.
From this answer to another question: a call to 'me/friends?fields=work' worked for me!
I'd suggest that you go to http://developers.facebook.com/docs/reference/api/user/ like most of the others are suggesting but as a general tip, use the friends_education_history as a way to get the friend's history.
P.S: Minor spelling error in your original question that should be edited. "education_histroy." = education_history
in the second line of your main paragraph.
You can use this code you will get name, profile picture, ID of your friends.
FB.api('/me/taggable_friends', function(response) {
for (var i = 0; i < friend_data.length; i++) {
results += ''+friend_data[i].name;
}
});
Before that in your developer account created app-> go to tools and support->graph API explorer-> click Get Token. In that window click user_tagged_places and click Get Access Token. You will get your friends list.