I've created an app for authorization users via Facebook, but not I need to get real ids for those users to be able to open their pages in the browser.
Is there any way to get current user page id by id which I've already received via Facebook api (app scoped id)?
I've trid this example but an error occurs: This method must be called with a Page Access Token
I've already passed access token. May be access token and page access token are different thing, idk (poor docs).
Also https://graph.facebook.com/v2.11/pages_id_mapping (pages_id_mapping ) method doesn't work for https://developers.facebook.com/tools/explorer.
I've also tried this example but it also doesn't work. It just returns exactly the same ids which have been passed.
This is broken too.
I can't believe that there is no way to get real user ids from app scoped ids..
I need to get user links.
Facebook no longer, under any circumstances, makes the real Facebook ID for a user available via the API.
If you request (and are approved for) the user_link permission, https://www.facebook.com/<app scoped ID> URLs will be enabled. You are still not permitted to attempt to translate these links into the underlying ID, but you can use them in your UI or to visit a user's page.
https://developers.facebook.com/docs/facebook-login/permissions/#reference-user_link
Related
What I want to achieve
I want to display posts of a public facebook page on my website. For that reason it does not make sense to use a user access token, since it requires a login.
Possible Solution I found
I know you can use the App Tokens. There was a related question on Stackoverflow. I tested this using the Graph API Explorer.
https://graph.facebook.com/v2.3/google/statuses
returns: (#100) Requires user session
https://graph.facebook.com/v2.3/google/posts
returns: a valid result, but a totally different result than the same request with a User Access Token (less posts). same request for nike delivers a better result.
Questions
Why does the same request deliver two diferent results?
Can you only grab certain posts with the app token?
Under which conditions can you get the full timeline without user access token?
It's all in the docs. There's a fundamental difference between posts and statuses, and the permission requirements are also well documented:
https://developers.facebook.com/docs/graph-api/reference/v2.3/page/feed#readperms
https://developers.facebook.com/docs/graph-api/reference/v2.3/status
*
Quotes:
An access token is required to view publicly shared posts.
A user access token is required to retrieve posts visible to that person.
A page access token is required to retrieve any other posts.
Firstly I am aware that there are a million questions similar to this, but they are all either out of date (Facebook has changed and the instructions no longer work) or don't explain how to do specifically what I am asking.
I'm trying to register an app on Facebook so that I can autopost to the company Facebook page, of which I am an admin.
I'm trying to do this via PHP, with which I have considerable experience (PHP, not Facebook API.)
So far I have registered as a Facebook developer, made a Facebook app, got the appID and secret word, and downloaded the facebook-php-sdk from Github. I have attempted to follow a couple of tutorials but the Facebook developer/app pages have all changed and so the intructions are now invalid.
All I want to do is to be able to post automatically to my page's wall from the server via PHP, as if I posted the status update myself as the page admin. I don't understand how or why this is so difficult.
The Facebook app page has a million settings that I've never heard of and don't seem to be related, then there is no information that gives any direction to do what I want to do.
This is about as far as I've got and I've hit a wall. No idea what to do next. Facebook keeps asking me "Select how your app integrates with Facebook" but their options don't appear to include what I want, which is just to post on my own page. I don't appear to actually be able to use the app yet, as there are various settings its insisting on, like "Canvas URL", which I do not understand, etc. and then I obviously need to set permissions, yet I see no way to do this either.
What do I do?
Setting up an app
You are going to need to authenticate the user who has at least content creator rights on your page. So you need to choose 'Website with Facebook Login' and enter your website url.
You'll also have to enter the domain (website url without protocol)
Keep it in sandbox mode while you test it you can edit that later.
You don't really have to worry about other settings as the permissions to ask can be added directly in your php code.
"Online" Access
To logging and post directly to facebook you'll need to retreive an access token
Getting an access token
Here is a basic run down:
Get user to login and allow app with appropriate permissions (manage_pages, publish_stream) if he hasn't
Retreive user access token
Query /me/accounts with user access token to get the page id & access token
Then all you have to do is make your API call with id & access token to post on facebook
"Offline" Access
In order to post without having to logging (usefull if you aren't the only one posting) you need a permanent extended token. So you basically should have a separate script that you'll run once to retrieve that extended token and store it.
Getting an extended access token
To be able to post without the user being logged in you need a permanent access token for your page.
Here is a basic run down:
Get user to allow app with appropriate permissions (manage_pages, publish_stream)
Retreive user access token
Change user access token for extended user access token
Here is how I do this step (you could also use curl)
$token_url = "https://graph.facebook.com/oauth/access_token?client_id=YOUR_APP_ID&client_secret=YOUT_APP_SECRET&grant_type=fb_exchange_token&fb_exchange_token=OLD_TOKEN";
$accessToken = #file_get_contents($token_url);
Then
Query /me/accounts with user extended access token to get the page
Change page access token for extended access token (same code as
above)
(The last step shouldn't be necessary according to the doc as you should get an extended page token when you query /me/accounts with an extended user token but in my case it didn't work)
And you get a permanent access token that only expires if the user changes password or disallows the app. All you have to do is store it with the page's id and retreive it wherever you need an API call to post to facebook.
The php sdk is pretty well documented so you shouldn't run into any problem a google search can't fix. Look for post september 2012 threads the flow hasn't changed since neither did the php sdk much.
I'm using the PHP SDK of Facebook to retrieve all sorts of information.
If you don't know, facebook keeps a temporary link for every video hosted on it and that link becomes inactive after a few days.
Therefor, I query FB using PHP with a vid to get it's url.
The problem is that I have to do that action even if a current user that's viewing my page isn't connected to my app.
Do you have any creative solution for me to query FB with a vid (video ID) even if the current user that's browsing my website isn't connected to my app?
(I could use an existing user token but now I have to control which tokens are alive and so on...)
Thanks!
If you're only going to query publicly accessible videos use your App Access token. Unlike an access token you obtain from a user, your app access token will not expire unless you reset your secret key. Take a look at this: https://developers.facebook.com/docs/opengraph/howtos/publishing-with-app-token/
I have a fair amount of Facebook development experience, but this had made me pull my hair. It must be something very small, but I can't get it. I recently saw some Facebook pages with welcome tabs that show user's name "Welcome [YOUR NAME]" who visits their page. Example is here:
https://www.facebook.com/Tony.Samaha.Official.Page
As per my knowledge, we cannot get the user id without the permissions by the user. After the permissions we are able to get the user id in the signed request. How do I get the Facebook user id or name, something similar to the above example? How is this working? Can this be achieved?
FYI: I am using iframe tab.
Check out the documentation on signed_requests. When a user visits your application there will be a signed_request posted to your URL. The documentation states :
A signed_request is passed to Apps on Facebook.com when they are
loaded into the Facebook environment
A signed_request is passed to any
app that has registered an Deauthorized Callback in the Developer App
whenever a given user removes the app using the App Dashboard
A signed_request is passed to apps that use the Registration Plugin
whenever a user successfully registers with their app
You will have to decode this request (see the link above for details) and from there you will be able to extract the user_id of the visiting user. Then all you have to do is query the Graph API like this :
https://graph.facebook.com/USER_ID and you will get back the public information for that user which should include the users name.
The user is still using the old static FBML application, so most likely they are using the fb:name tag. Though, I believe this is now deprecated. So really, the page you linked to needs to be updated.
I am integrating GFC with my web app (PHP). In this app I have a list of user IDs and I need to fetch their profile details like their display name, profile pic url etc. using a HTTP call.
For example, I am trying to fetch data of user with id: $userId = 1234567
If a viewer (need not the user with above id) is logged in, I am able to fetch data by making a call to following URL.
http://www.google.com/friendconnect/api/people/$userId/#self?fcauth=$fcauth
But, if viewer is not logged in, the above URL replies the following
Anonymous requests are not allowed to fetch data
Error 401
I would like to know what URL should be used to fetch the user data even if no one is logged in.
Thanks!!
The fcauth mechanism is designed for access while the user is online. The fcauth tokens expire fairly rapidly, and no guarantee is made about how long they're valid for. You should assume that they'll only work while the user is online.
If you need offline access, you need to use OAuth. OAuth tokens are valid until manually revoked.
The API call you're making is the correct one, you just need to do it with OAuth instead of fcauth.