I am using the following script to post a link to the wall of Facebook page:
ini_set("zend.ze1_compatibility_mode", "off");
require_once('facebook-php-sdk/src/facebook.php');
$appId = 'XXXXXXXXXXXXXX';
$secret = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$facebook = new Facebook(array('appId' => $appId, 'secret' => $secret));
$access_token = file_get_contents('https://graph.facebook.com/oauth/access_token?client_id='.$appId.'&client_secret='.$secret.'&grant_type=client_credentials');
$access_token = preg_replace('/^access_token=/', '', $access_token);
$attachment = array(
'access_token' => $access_token,
'message' => 'message text',
'link' => 'http://www.domain.com/',
'name' => utf8_encode('link title'),
'description' => utf8_encode('link description'),
'picture' => 'http://www.domain.com/images/picture.jpg'
);
$facebook->api('/XXXXXXXXXXXX/feed', 'POST', $attachment);
It was working quite fine but since 2 weeks it started trowing the following error while absolutely no modifications were made:
Fatal error: Uncaught OAuthException: An unknown error has occurred.
thrown in /path/to/public_html/facebook-php-sdk/src/base_facebook.php on line 1033
By some primitive debugging I found out that if I comment out link element of $attachment array the problem went off. However it resulted that name at the Facebook page starts linking to picture file which is definitely not an option.
Any help will be highly appreciated.
UPDATE:
I tried to execute this request through Graph API Explorer and got the same error:
{
"error": {
"message": "An unknown error has occurred.",
"type": "OAuthException",
"code": 1
}
}
I’m having the same issue, with a simple web based program that occasionally updates my client’s facebook page with status updates about his inventory.
From what I can tell, for whatever reason this bug has been placed in a “Won’t Fix” status and the feature in question has been deprecated?
https://developers.facebook.com/bugs/397106947003500?browse=search_5013a59fc630a7b70100468
I don’t know why JUST THE LINK FUNCTIONALITY would be deprecated, nor do I know what the new correct method is to post a link, since the Graph documentation still lists “link” as the correct field to use to do so. Anyone?
On the bug page above, he gives a link that supposedly gives more info, but the link doesn’t work. I assumed that maybe the “.intern” portion wasn’t supposed to be there, giving me this URL…
https://developers.facebook.com/blog/post/2012/07/25/platform-updates–operation-developer-love/
…which DOES work, but I don’t see any information on there that is relevant to the deprecated feature, or that otherwise helps me determine how to change my code to post a link. Perhaps someone more knowledgeable about the Graph API can help!
[I really do wish Facebook would stop deprecating stuff; would it really have done any harm to allow this to continue to work? They call it Operation Developer Love, but how can I love something that causes me extra work for no reason?]