The situation
I'm developing a web tool that will be used inside a iPhone/Android app.
Inside the app the User have to log into facebook, with the FB app or a regular fallback.
We discovered that the FB session between the app and the webview was not carried over. (If you logged in on FB in the app, you still had to log in to FB in the webview)
To solve this we made the App send the access token to the webview through a POST.
In the web view I use the Graph API to fetch the users FB ID.
The ID is used in a API that the App and the webview-site uses to share data.
So far so good.
The Problem
We want to use a share dialog on some parts of the webview.
But we don't want to login again (We want to use the Access Token for this as well)
(I cannot do any changes to the App itself so I'm stuck with what I have.
A Access Token)
Tries
1) I have tried to find if it is possible to use a regular Share Dialog with a Access Token. It doesn't seem to work from the documentation.
2) It doesn't work to "login" to FB with a access token from what I can tell. No way to pass the Access Token.
3) I can't create a Share Dialog with FB.ui since that function doesn't take a Access Token.
4) Using the URL Redirection method doesn't work either because you will get a login dialog. (Since I can't pass the Access Token from what I can tell)
5) I can post directly to a users feed with fb.api() and the "publish_actions" permission. With fb.api() I can pass the Access Token to the function. But the user can't control what is being sent. I'm worried that might anger users.
I could build a custom dialog for the user and send what they wrote there. That is a last resort if no other solution is found.
When I tried to test this solution in the Graph API Explorer my FB account accused my app for spamming.. So I'm not sure this is a valid solution.
Conclusion
It seems very difficult to share content with only a Access Token.
Solution nr 5 works but I would rather use a regular share dialog.
I know that it seems impossible according to the documentation but FB are not the best at updating their documentation. So I'm hoping someone can give me a definite answer.
Resources
If I understood correctly I'm only allowed to share 2 links, since I don't have enough reputation.
https://developers.facebook.com/docs/plugins/share-button
https://developers.facebook.com/docs/javascript/reference/
you can use this.
https://www.facebook.com/dialog/share?
app_id=xxxxxxxxxx&display=popup
&href=http://google.com
&access_token=<user access token>
check your app access token first at
graph.facebook.com/debug_token?
input_token={token-to-inspect}
&access_token={app-token-or-admin-token}
check that your app has access to user public-profile
graph.facebook.com/debug_token?
input_token=
&access_token=
Related
I am creating an application which connects to a FB app and allows users to login via FB to my application. When login to application using oauth, it will provide a User Access Token. Can i use that token to get list of pages and page access tokens that created by user using User Access Token?
The ultimate target is this project is accessing/managing pages that created by logged users via our own application.
Please tell me possibility of this thing and let me know if you have any other suggestions.
Thank you.
Regards,
Sahan.
Sure, you simply need the right permissions in your login flow. A good overview is listed here: https://developers.facebook.com/docs/pages/access-tokens
You should have a look at the page access token, because they are required as soon as you work with pages.
BTW, afaik it is not possible to create pages with a Facebook app and according to the Graph API reference only updating page information is possible.
Unfortunately I'm struggling to understand the documentation provided by Facebook.
This is the scenario:
- Some of my iPhone Apps are also registered as Native/Desktop Apps on Facebook in order to support the Facebook Audience Network.
- I'm building a tool in python which will retrieve data from the reporting API in order to run some automated analysis on specific metrics (request, impressions and so on).
The question is: how do I retrieve this data?
The documentation for the reporting API is here: Reporting API
However I'm struggling with the access token.
It says that I could use the specific App Token available here: App Tokens
However by using such token, I get an error saying that app tokens can't be used for Desktop/Native Ads.
What is the correct way to do it then? Here is where I struggle to understand Facebook Documentation.
My guess is that I should use a User Access Token instead, generated for a user that is also the admin of the App for which I want to retrieve the insights.
What really freaks me out is that apparently, this can't be done with normal HTTP calls only but it requires instead to go through the Facebook Login Dialog. I also need to create another Facebook (web) app because there is no way to get a simple "User Object"... Everything needs to start and go through a registered Facebook App. And there's no way to go through these steps by using backend code only.
So... to recap... in order to read the Insights for a Native/Desktop Facebook App (APP_A), I have to:
- Create a new Web Facebook App (APP_B)
- Create a web interface somewhere for APP_B) which will trigger the Facebook Login Dialog and request the read_insights permission.
- Login through this web interface and generate a User Access Token
- Put this User Access Token in my backend code and run the scripts that retrieve the data provided by the Reporting API for APP_B
Really... to me... it doesn't make any sense to create a new Facebook App in order to access the data of another Facebook App.
Isn't there another better, simpler, quicker, cleaner way to achieve the same final result?
I want to use the Facebook (Graph) API to show a list of names and pictures of friends of a facebook account (which I own). Do I really need to register my website as an app for this? Since I don't really think of my website as an app... Or can I somehow get an access token that doesn't expire since I can grant access to this list of friends myself?
Think of an app on Facebook as an API Key. Your App is how Facebook identifies who is making the call, what permissions you have, and if you are abusing the system or not.
And no, you can't get access to most Graph API data without a valid Facebook App.
i am trying to use /me/likes/pageID the same way i used pages.isFan (REST API).
But it always uses the user/page as me for which i created the access token and not the current active user.
can't get my head around this one, any help is appreciated!
thanks
[from comments] but do i really need to create an application to "just" check if the user is fan of my own page? and even ask his authorization?
Yes, you will need an app in any case.
If you run your app as a canvas or page tab app inside of Facebook, then you get the info if the current user liked the very Facebook fan page the app is running in(!) directly from the signed_request parameter.
If you want to query this infor for other pages, and/or your app is running outside of Facebook, then you have to have the user connect to your app and ask permission to read his likes first, before you can get this info.
For information on the latter case, see https://developers.facebook.com/docs/authentication/, https://developers.facebook.com/docs/authentication/permissions/#user_friends_perms, https://developers.facebook.com/docs/reference/api/user/#likes
It is easy: With the new Graph API, the owner of the access token is me. You can see this by pasting an access token into the debugger.
You should be authenticating your user and gaining an access token in their name each time they visit your site. Then use only this access token when you make your query.
This process is easiest if you use one of the Facebook SDKs.
I'm trying to use the facebook API on the backend of a website. Essentially, I want to be able to create events using a Djano app and have it create the corresponding facebook events.
The organization I am creating events for already have a facebook page. I only am concerned with posting events on that organization's page. I am the admin for the organization so I know all the login info.
What I am am trying to figure out is how I can setup the access token such thatit just works for the organization without any need to login to the facebook app. I was thinking that setting a static access token would do the trick, but I cannot find anyway to do it.
So, what is the standard way to create a facebook app that only interfaces with one predefined user?
Im not entirely sure what you're trying to do. However the static access token has now been deprecated. Do you want to: create an event for the person using the page, or for the company's page/profile?
Hope I can help