facebookarchive / php-graph-sdk

The Facebook SDK for PHP provides a native interface to the Graph API and Facebook Login. https://developers.facebook.com/docs/php
Other
3.17k stars 1.96k forks source link

unknown error occures when posting to page #1141

Open saleempbt5 opened 5 years ago

saleempbt5 commented 5 years ago

I have used php curl to post links with images to a facebook page, unfortunately it gets error as response in sometimes

i have used the following code

$url = "https://graph.facebook.com/".$pageId."/feed";
$attachment =  array(
'access_token' => "Token",
 'link'    =>$uris,
    'picture' => $imgurl_url,
    'name'    => $title,
    'description'=>$description,
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $attachment);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  //to suppress the curl output
$result = curl_exec($ch);
curl_close ($ch);
$ary = json_decode($result);
if(isset($ary->id)){
echo "Posted to facebook";
}

Even sometimes the response is error with subcode 99, the link gets posted to the page. the response i getting for this call is {code=>1, "unknown error occured", subcode:99}