Answer the question
In order to leave comments, you need to log in
Why does the Facebook API key flies all the time to send a message from the site to the group wall?
Good day.
There is a website (admin panel, PHP), the operator composes a post, clicks on a button, and this post goes to the community page on Facebook (and to other social networks in the same way, but there are no problems there).
The problem is that for some reason, once a week (or less), my Facebook API key flies (from the Graph API Explorer that I get) and I have to go to https://developers.facebook.com/tools/explorer to choose desired group, select a group token, and generate an access token again.
I use the official PHP lib from Facebook, and here is the content of the file that actually makes the request:
header("Access-Control-Allow-Origin: *");
require_once 'src/autoload.php';
$app_id = "<APP ID>";
$app_secret = "<SECRET KEY>";
$group_id = "<GROUP ID>";
$token = "<TOKEN ИЗ TOOLS EXPLORER>";
$fb = new Facebook\Facebook([
'app_id' => $app_id,
'app_secret' => $app_secret,
'default_graph_version' => 'v2.10',
]);
$linkData = [
'message' => $_POST['msg']
];
try {
$response = $fb->post("/{$group_id}/feed", $linkData, $token);
} catch(Facebook\Exceptions\FacebookResponseException $e) {
echo 'Graph returned an error: ' . $e->getMessage();
exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
echo 'Facebook SDK returned an error: ' . $e->getMessage();
exit;
}
$graphNode = $response->getGraphNode();
Answer the question
In order to leave comments, you need to log in
select the desired group, select the group token, and generate an access token again.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question