Facebook Graph API access with client token/anonymous?
I'm working on an iOS app where the users need to be able to access the Facebook Graph API without having a Facebook login (because they signed up for my app as email-only). They mainly need to retrieve other Facebook users' public feeds (celebrities, etc) so that I can display that info in about boxes. In the old API, I believe this was called public post search or offline access, but those seem to have since been deprecated by Facebook. I'm wondering if using the app-id as the token directly would work:
How to get a Facebook access token for a page with no app or app secret
In place of that, could I use the "Client Token" at:
https://developers.facebook.com/apps/{your-app-id}/settings/advanced/
along with:
[FBAccessTokenData createTokenFromString:]
[FBSession openFromAccessTokenData:]
to log the user into Facebook using my app's credentials? Another option might be to log the user in as anonymous programmatically:
https://developers.facebook.com/products/anonymous-login/
I'm having difficulty finding the corresponding calls in the FacebookSDK.framework. The only mention of "anonymous" that I could find was:
[FBSettings setClientToken:]
From the documentation: "Sets the Client Token for the Facebook App. This is needed for certain API calls when made anonymously, without a user-based Session."
If none of this is possible, then I may need to fall back to using a node.js server to generate a long-lived token for the user from the app token. This is discussed in the "Generating Long-Lived User Tokens from Server-Side Long-Lived Tokens" section of:
https://developers.facebook.com/docs/facebook-login/access-tokens
I see how to possibly get a token here:
https://developers.facebook.com/tools/access_token/
https://developers.facebook.com/tools/explorer/?method=GET&path=me%3Ffields%3Did%2Cname&version=v2.2
And then use node.js to somehow extend that and pass it to the client:
facebook: permanent Page Access Token?
Obtain new Access Token without Facebook Login
Or skip getting a token altogether by using app_id|app_secret in place of a token:
trying to get app access token
But its not clear how this could be passed from node.js back to the client. I'm feeling very confused about all of this and don't understand why accessing public data with the graph API is not better documented. I have normal user login working in iOS and could adapt an anonymous login example from the web if I could find one. Any examples would be greatly appreciated.
UPDATE:
These instructions and these docs helped me create a long-lived token from the app id that could be used for Facebook API access. This is done through a back end server like php for now, but it might be possible to adapt it to iOS with URL requests (obviously, you would only share the token with clients, not MY_CLIENT_SECRET). I have not looked into what happens when many clients make requests to the Facebook API by way of an app's token.
链接地址: http://www.djcxy.com/p/32594.html