I tried to make an ajax call for creating a test page using a test user by following the tutorial from here https://developers.facebook.com/docs/apps/test-pages. But return an error exception,
I tried to store the test user account access token as a sesstion after it is logged in.
Supposed
$_SESSION['fb_access_token']
create_page.php
$fb = new FacebookFacebook([
'app_id' => '226057574774907', //test app_id
'app_secret' => '83e135ab7849067a4e109489cb4f1258', //test app_secret
'default_graph_version' => 'v3.0',
]);
`if (isset($_SESSION['fb_access_token']))
{
try {
$params= array(
"category_enum"=>"PERSONAL_BLOG",
"name"=>"hkinstant",
"about"=>"trying some things with the API",
"picture"=>"https://hkinstant.me/img/banner.png",
'cover_photo' => "https://hkinstant.me/img/cover.jpg"
);
//create page
$request = $fb->sendRequest('POST', '/me/accounts', $params,$_SESSION['fb_access_token']);
}
catch (Facebook\Exceptions\FacebookResponseException $e) {
//Wehn Graph returns an error.
echo 'Graph returned an error :'.$e->getMessage();
exit;
} catch (Facebook\Exceptions\FacebookSDKException $e) {
// When validation fails or other local issues
echo 'Facebook SDK returned an error: ' . $e->getMessage();
exit;
}
$result = $request->getDecodedBody();
echo json_encode($result);
}
}`
What's wrong with the parameter "cover_photo"?
'cover_photo' => "https://hkinstant.me/img/cover.jpg"
cover_photo param is not expected to be an URL but rather an OBJECT
see here:
https://developers.facebook.com/docs/graph-api/reference/user/accounts/#Creating
Most helpful comment
'cover_photo' => "https://hkinstant.me/img/cover.jpg"
cover_photo param is not expected to be an URL but rather an OBJECT
see here:
https://developers.facebook.com/docs/graph-api/reference/user/accounts/#Creating