facebook: permanent Page Access Token?

后端 未结 16 2189
情书的邮戳
情书的邮戳 2020-11-22 02:39

I work on a project that has facebook pages as one of its data sources. It imports some data from it periodically with no GUI involved. Then we use a web app to show the dat

16条回答
  •  自闭症患者
    2020-11-22 02:59

    Application request limit reached (#4) - FB API v2.1 and greater

    This answer led me to the "ultimate answer for us" and so it is very much related so I am appending it here. While it's related to the above it is different and it seems FB has simplified the process some.

    Our sharing counts on our site stopped worked when FB rolled over the api to v 2.1. In our case we already had a FB APP and we were NOT using the FB login. So what we needed to do was get a FB APP Token to make the new requests. This is as of Aug. 23 2016.

    1. Go to: https://developers.facebook.com/tools/explorer
    2. Select the api version and then use GET and paste the following:

      /oauth/access_token?client_id={app-id}&client_secret={app-secret}&grant_type=client_credentials
      

      You will want to go grab your app id and your app secret from your app page. Main FB Apps developer page

    3. Run the graph query and you will see:

      {
         "access_token": "app-id|app-token",
         "token_type": "bearer"
      }
      

      Where

      "app-id"
      and
      "app-token"
      will be your app id from your FB app page and the generated FB App HASH you just received.

    4. Next go test your new APP access token: FB Access Token tester

    5. You should see, by pasting the

      "app-token"
      into the token tester, a single app based token without an expiration date/time.

    In our case we are using the FB js sdk so we changed our call to be like so (please note this ONLY gets the share count and not the share and comment count combined like it used to be):

    FB.api(
        '/','GET',{
        // this is our FB app token for our FB app 
            access_token: FBAppToken,
            "id":"{$shareUrl}","fields":"id,og_object{ engagement }"
    }
    

    This is now working properly. This took a lot of searching and an official bug report with FB to confirm that we have to start making tokenized requests to the FB api. As an aside I did request that they (FB) add a clue to the Error code (#4) that mentions the tokenized request.

    I just got another report from one of our devs that our FB comment count is broken as well due to the new need for tokenized requests so I will update this accordingly.

提交回复
热议问题