Fix Facebook perm token request

Created on 7 November 2024, 9 days ago

Problem/Motivation

I'm trying to get Feeds from FB, but got errors.

After debugging I have found that issue is in part where permanent token should be fetched

 // Permanent Token.
      $request = $client->request('GET', $url . "/$account_id/accounts?access_token=$long_token");
      $request = json_decode($request->getBody()->getContents());
      foreach ($request->data as $response_data) {
        if ($response_data->id == $page_id) {
          $config->set('page_permanent_token', $response_data->access_token)->save();
          return $response_data->access_token;
        }
      }

Response data is empty for this request.

Proposed resolution

I have found that permanent token can be fetched with request to https://graph.facebook.com/{graph_version}/{page_id}?fields=access_token&access_token={long_lived_token}

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇷🇺Russia sorlov

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024