I'm now trying pynder, but it requries you to get a facebook ID and access token.
The facebook ID is what each user has in its own page, such as https://www.facebook.com/profile.php?id=YOUR_ID if I understand it correctly.
However, I don't understand how I get the access token. I first tried to get with this tutorial, but since it is outdated, the actual pop-up page showed two types of ID: Get Use Access Token and Get Access Token. So I registered Facebook Developer program.
Then, I didn't know which to pick, but I tried both anyway. The page didn't show read_stream, by the way. However, I didn't get a correct response when running curl:
curl -X POST https://api.gotinder.com/auth --data '{"facebook_token": fb_token, "facebook_id": fb_user_id}'
This issued an error: {"code":401,"error":"FacebookTokenRequired"}.
How can I get the correct access token to run the program?
the following link may help you
Getting Facebook Access Token from User Id and Facebook App Secret?
Getting Facebook User access tokens:
Step 1: goto : Facebook Graph Explorer
Step 2: Locate and select Get Token in dropbox on right and copy the token from text Box
Bonus Step3 : To get User ID associated with access token : click the blue info icon at the starting of text box
You can get your access token through the Facebook Access Token Tool
Related
I create a demo application to request photos from facebook. I created an application token like this : 549933848476397|4a584ce5fda19cba2ed6630ed78ba8f4. But when use this request URL https://graph.facebook.com/1417833425116725/photos?access_token={app_id}|{app_secret}. It's does not work. Please help me. Actually When I use user token for this request, It's work ok.
If the Page is restricted somehow (age, location), you can only use a User or Page Access Token to get data like photos of the Page. The App Access Token got no relation to any User, so Facebook canĀ“t detect if the User is even allowed to see the Page.
I am 100% sure the Page is restricted btw, you get an "Unsupported get request" error when trying to access the Page ID directly with the Graph API, and that usually happens when the Page is restricted.
Just try another Page with that exact same App Access Token, for example:
/bladauhu/photos
...works without any problem. Another sign that your Page is indeed restricted.
TL;DR: For this specific Page, you MUST use a User Token or Page Token.
I wrote a python script that runs on a cron job on my server that posts to my facebook account for me using my own facebook app. Unfortunately, every couple months, I get:
Response: {u'error': {u'message': u'Error validating access token: Session has expired...', u'code': 190, u'type': u'OAuthException', u'error_subcode': 463}}
Every time this occurs, I have to log into facebook, get a new code -> access token.
I'd like to fully automate this so that I can get a new access token without ever logging into facebook. What's the best way to do this?
I'd prefer a way to do this without storing my password on my server or accessing facebook via curl (which would be a hack), but--worst comes to worst--I suppose I could just login to facebook with curl to get the code -> access token.
Please don't tell me to use offline_access (as most of my searches show). That's been deprecated.
TIA!
edit: here's how I currently re-auth (this requires me to log into facebook):
log into facebook in browser
visit in browser: https://www.facebook.com/dialog/oauth?client_id=XXX&redirect_uri=https://www.facebook.com/connect/login_success.html&scope=publish_actions
extract $code returned from facebook
curl "https://graph.facebook.com/oauth/access_token?client_id=XXX&redirect_uri=https://www.facebook.com/connect/login_success.html&client_secret=YYY&code=$code"
store updated access_token that's returned from facebook
That is exactly how it is supposed to be. There is no way (anymore) to get a User Access Token that is valid forever. No app should be allowed to use a Token of a User who did not open the App in more than 60 days.
One solution is to create a Facebook Page and use an Extended Page Access Token, because those are valid forever. Here are a couple of links with all the information you need:
https://developers.facebook.com/docs/facebook-login/access-tokens/
http://www.devils-heaven.com/facebook-access-tokens/
http://www.devils-heaven.com/extended-page-access-tokens-curl/
I am trying to delete an application tab from a facebook page.
According to the documentation, I should issue a DELETE request to "https://graph.facebook.com/PAGE_ID/tabs/app_ID" with a "manage_pages" access token, but when I do so I get the error "(#210) Subject must be a page."
I have requested the user for "manage_pages" permission and I have the correct access_token (GET Method works perfectly to show all the details).
The exact request is:
https://graph.facebook.com/270936169730418/tabs/app_533644953422033 (with an access token)
Does anyone know what am I doing wrong??
P.S I am using JS SDK and also trying to do this in the graph api explorer but results are the same.
The problem is with the access token. When using the Graph API Explorer (and checking "manage_pages") you might think that the access token showing at the top is a page access token. It is not.
You need to do GET /me/accounts
Then find the page you want and there is an access_token. Copy this and paste it into the Access Token input field at the top. Now do the DELETE [PAGE_ID]/apps_[APP_ID] and it will work.
I am trying to get events from a Facebook page via Ajax.
But there should be no login process for user. For this reason I am trying to implement "Login as an App" by following the the documentation on this page.
I am getting the access token correctly by
https://graph.facebook.com/oauth/access_token?
client_id=YOUR_APP_ID
&client_secret=YOUR_APP_SECRET
&grant_type=client_credentials
However when I try to query Facebook Graph API with this access token I am getting an empty result set.
This is an example request;
https://graph.facebook.com/FAN_PAGE/events?access_token=ACCESS_TOKEN
I know the result set should not be empty because the same request with Graph Explorer returns the correct values.
Even a request like https://graph.facebook.com/FAN_PAGE/events?access_token=ACCESS_TOKEN_FROM_GRAPH_EXPLORER works correctly.
Any idea on whats going on? How can I get this to work correctly?
Actually the reason was not about the access token. The reason is that the page I want to get the events for is restricted. This works fine for unrestricted pages.
After a little research I found out that to read a restricted page's events (or posts etc.) you need a user access token. You get this by asking the user. (at login flow)
The other solution to get this data without prompting for a login is to get "page access token". You can generate a page access token by following this link.
And more on Access Tokens
I am trying to read the inbox and outbox of a Facebook Page. My first approach was to try to directly access the inbox of a page node. The URI below indicates how I tried to get it:
/{page-id}/inbox
Here is the error message:
You can only access the \"inbox\" connection for the current user.
Then I tried to access the conversations and threads edges as suggested in some places like so:
/{page-id}/conversations
/{page-id}/threads
Both URIs produce the following error:
(#298) You must be a developer of the application
I couldn't figure out what is wrong at all? There are some bug reports to Facebook, related to "#(298)", which were reported a few months ago but I can't believe it hasn't been fixed so far.
Any alternative approach is welcome.
This problem happens if you use a user access token instead of a page access token.
I was doing this in the Facebook Graph API Explorer and I thought I was using the page access token but I wasn't. When I ran {page-id}/conversations?access_token={page_access_token} from the API Explorer, it had the {user_access_token} in the Access Token field at the top. This was being sent in the actual request that the Explorer sent (as seen in Chrome's dev tools). I.e., the API Explorer was ignoring the {page_access_token} I entered and was using the value in the Access Token field.
Clearing the Access Token field or entering the {page_access_token} in that field resulted in the intended {page_access_token} being sent. Doing some of the steps in the browser vs the API Explorer showed me the way.
These are the steps to resolve the issue:
Get a user access token: with manage_pages and read_page_mailboxes permissions* by clicking Get Access Token from the API Explorer and selecting the specified permissions or visiting the URL below.
https://www.facebook.com/dialog/oauth?client_id={app-id}&redirect_uri={redirect-uri}&request_type=token&scope=manage_pages,read_page_mailboxes
Get a page access token: by running /me/accounts from the API Explorer or by vising the URL below.
https://graph.facebook.com/v2.0/me/accounts?method=GET&format=json&suppress_http_code=1&access_token={user-access-token}
Get conversations: Use the page access token (paste it in the Access Token field if using the API Explorer) from the above step to get conversations** by running /{page-id}/conversations or by vising the URL below.
https://graph.facebook.com/v2.0/{page-id}/conversations?method=GET&format=json&suppress_http_code=1&access_token={page-access-token}
* read_mailbox permission is not required, contrary to what I said in my comment above. Actually, the error message was incorrect, attempting to access Page edges with a user access token incorrectly gives user access errors instead of invalid Page access token errors.
** The user must be an admin of the Facebook Page to access its conversations.