简体   繁体   中英

Get Public Photos from Facebook Page without Requesting Access Token

I'm looking over this Facebook API documentation and it can't be true that in order to read in a page's public photos, you need to ask the user for permission to connect with THEIR Facebook account?

Something like this fails.

/* make the API call */
FB.api(
    "/{album-id}",
    function (response) {
      if (response && !response.error) {
        /* handle the result */
      }
    }
);

Error says:

"An access token is required to request this resource."

So then now I can't find a way (that isn't out of date) to have an API call get an access token without prompting the visitor to accept anything.

What am I overlooking?

Update: this works. And I know not to store the app secret on the client side.

FB.api(
    '/{album-id}',
    'GET',
    {'access_token':'{app-id}|{app-secret}'},
    function(response) {
        /* handle the result */
    }
);

If the Page is not restricted by age or location, you can use an App Access Token (App-ID|App-Secret). If the Page is restricted, you can authorize a Page Admin with the manage_pages permission and request an Extended Page Token - it is valid forever, as the App Access Token.

More information about Tokens:

Important: You should not use those Tokens on the client, the are always meant to be kept secret. You should use the Token on the server and implement some caching, or you will hit API limits if you get a lot users/hits.

如果它是“公共”照片/相册,则可以使用应用程序访问令牌<APP_ID>|<APP_SECRET>可以用作应用程序访问令牌,但是您切勿在客户端公开应用程序的机密,就像密码一样对您的应用程序)进行查询。

\GET /<api>?access_token=<APP-ACCESS-TOKEN>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM