Post to user page from app on server - facebook

I have got the APP token using https://graph.facebook.com/oauth/access_token
I have got the usser access token using https://www.facebook.com/dialog/oauth?client_id
I now what to to publish on the user FaceBook page and it appears I need to USER_ID
Where is that?
I am looking to publish using https://graph.facebook.com/[USER ID]/feed

The user id is the number or facebook user of the user where you want to post...
When you see the url from your home you see:
https://www.facebook.com/profile.php?id=4
https://www.facebook.com/zuck
In this case you can use 4 or zuck for that.

Related

Do review required if we want to get Facebook Page like count (Without Facebook login) by Facebook app token?

I am doing a static web page in my website, in which I am showing the like count of particular Facebook page. There is no kind of login required to see this web page. Also, I don't want to user to login with their Facebook account to see the Facebook page like count.
I have implemented this requirement by using Facebook app token.
API: "https://graph.facebook.com/PAGE_ID?access_token=APP_TOKEN"
But the problem here is, If I use the app token of already approved app by Facebook with some permissions (manage_pages) exists, it works. It is not working for the app token of newly created Facebook app.
I have sent the app for review to Facebook by requesting manage_pages permission, but they rejected the app and said that my website doesn't have the Facebook login functionality implemented.
Since it is not documented clearly, I have a doubt that do the app need to send for review if I want to get the Facebook page like count without Facebook login (By using Facebook app token)? If yes, what permission do I want to request?
Any help would be much appreciated.
First of all, you need to learn what Tokens there are:
https://developers.facebook.com/docs/facebook-login/access-tokens
http://www.devils-heaven.com/facebook-access-tokens/
For your problem, you can just use an App Access Token. There is no need for any permission or Login Review, the links above tell you exactly how to create one. Make sure you never use the Token on the client, especially because it includes the App Secret. Do the API call on the server only (file_get_contents or curl, if you use PHP).
If by "it does not work" you mean that you only get the id and the name, then it´s not about "not working", you need to read the changelog and search for "Declarative Fields": https://developers.facebook.com/docs/apps/changelog#v2_4
So if you want to get more than just id and name, the API call would be like this: https://graph.facebook.com/936299239766048?access_token=YOURAPPTOKEN&fields=id,name,likes,...

Do i need the Facebook PHP SDK for Page Tab Apps?

I'm developing a Facebook Page Tab App. The files are located on my own server and i've created a Facebook App.
Now i'm trying to access the user's first name and i found different ways to get user informations, e.g. the $signedrequest (for the user ID) or the Facebook PHP SDK.
So do i need the SDK, e.g. for Graph API calls, or are there other ways to get informations from Facebook in my Page Tab App?
Using the SDK i get a lot of errors like An active access token must be used to query information about the current user., even if the user is already logged in.
If the user have not signed in to your app you will not get the user name or user id from the singend request parameter. It will give you information if the user likes the page, is admin of the page and additional app_data.
Using the php-sdk you can use the getLoginUrl() method, https://developers.facebook.com/docs/reference/php/facebook-getLoginUrl/, to get the access token needed to fetch user name, user id etc.

Auto post with facebook

I'm using facebook login (with facebook api) for one of my web application .
After user logged with their FB account I'm assigning secret unique code for the user in my application side .
So now I need to login to the particular user FB account automatically and post pre-defined message on that user wall when user enter that unique code (Actually users are using RFID tags sometimes they will enter that code manually)
So Is it possible to do that automatic login to the FB ?
Sounds a bit fishy ....
still:
https://developers.facebook.com/roadmap/offline-access-removal/
you can extend a users token for 60 days ...
cheers

Getting a user's ID using Facebook's Graph API

Is it possible to get the ID (Facebook Graph API) of a user who is currently logged in, without any access tokens?
If not, then how do I get new access tokens every time a user visits my page?
You will need to init the Facebook Javascript SDK and the user will have to have authorized your app at least one time. After that when the user visits your page as long as they are logged into Facebook you'll have access to the id and can retrieve it using
FB.getLoginStatus
the response will contain the information you're looking for.
Check this blog post for more details on setting up the FB init and the initial login.
https://developers.facebook.com/blog/post/525/
You can check the facebook ID using their username
http://graph.facebook.com/radrivan
You can use the javascript sdk to get their accesstoken and let them allow your app.
https://developers.facebook.com/docs/facebook-login/login-flow-for-web/v2.2

Facebook Graph API: Reuse the code verification string?

The authorization section of this page developers.facebook.com / docs / api contains a good description on how to perform authentication for a user agains my Facebook app. However, in my scenario I cannot get it to work the way I want. Here is how it is supposed to work:
User comes to my login page and clicks a "Sign in with Facebook" link.
User gets redirected to graph.facebook.com / oauth /authorize?[some params] and authorizes my Facebook app to access his/her data. Facebook redirects back to my site.
My site checks the Code parameter, calls Facebook to replace it for an access token, and then lets the user connect his/her account on my site with the account on Facebook. The access token is saved on the user account on my site.
The next time user arrives at my site and want to login, he/she should be able to click the same "Sign in with Facebook" link and directly get signed in with the site account (assuming he/she is still logged into Facebook)
Problem: Each time the code (from graph.facebook.com / oauth/authorize) is replaced for an access token, the token is changed. Since that token is used to look up the user in my site database, the matching failes.
My question is now: How do I solve this problem? Can the Code parameter from graph.facebook.com /oauth/authorize be saved and used over and over again to look up user? Or is there another way to do this? I really would prefer NOT using the Javascript API since it gives me lots of other troubles.
[Sorry about the links, I am a new user and not allowed to post more than one link]
Ah, I solved it: After I got the access_token I just call graph.facebook.com/me to get the id of the user. This is saved to my database. Next time I match against that id.