Reputation: 61
Facebook post to page, SDK 5 php.
Like the titel says, "Graph returned an error: Unsupported post request.
" I can't figure out why I'm getting it, tried every tip I've found both here on Stackoverflow and other websites.
I've tried to change settings in the app and page, tried small changes in the code, diffrent tokens and so on. Any tips on how I should proceed?
session_start();
include ('../assets/db_conn.php');
require_once __DIR__ . '/FacebookSDK/src/Facebook/autoload.php';
include('fbData.php');
$fb = new Facebook\Facebook($fbData);
$access_token = '**';
//////////*DB CONNECTIONS HERE*////////Took it away to make the code cleaner
$pages = $getFbPages->fetchAll();
$params = array();
$params["message"] = 'test1';
$params["link"] = 'http://***.se';
$params["picture"] = 'https://www.****.com/WNI01_14-Logo-275x63.png';
$params["description"] = 'testar en beskrivning';
foreach ($pages as $page) {
$pageID = $page['pageId'];
// post to Facebook
try {
// Returns a `Facebook\FacebookResponse` object
$response = $fb->post('/'.$pageID.'/feed', $params, $access_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();
}
Upvotes: 0
Views: 589
Reputation: 328
error is due to your domain name or call back URL that you provided in App creation but may be you are testing on any other URL. Your testing URl must be sub domain or any other related to your domain
Upvotes: 0