Error posting message with link to Facebook

We are trying to post from PHP to a Facebook, we are using HybridAuth but the question is not related to it. What works: -posting to user profile, works fine,including when using picture and link -posting to page works including image(but not with link) What does not work -posting to page when we set a link(the url is not the issue since it works posting it to user profile )

The error is a generic error, that is not helping at all,thank you Facebook developers for giving us the trouble of guessing what is wrong

{"error":{"message":"An unknown error has occurred.","type":"OAuthException","code":1}}

I also made a simple script using curl to test this without involving the HybridAuth code and I get same error

<?
$access_token = "xxxxxx";
$page_id="352300454896456";
$msg = "test message ".time();
$title = "test title";
$uri = "http://www.example.com";
$desc = "test description";
//$pic = "http://ploscariu.com/simion/programming/kudani/kudani.png";

$attachment = array(
    'access_token' => $access_token,
    'message' => $msg,
    'name' => $title,
    'link' => $uri,
    'description' => $desc//,
//'picture'=>$pic,
//'actions' => json_encode(array('name' => $action_name,'link' => $action_link))
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://graph.facebook.com/'.$page_id.'/feed');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
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);
print_r($result);
curl_close($ch);
?>

My question is, what is special about this "link" parameter and page posting? do we need some undocumented permission ? or is just some graph API bug I am wondering if we need sme different token for posting links ,but usually permission issue get back a good error message

在这里输入图像描述

in the image is the debug tool results on the access_token I get from the HybridAuth call, I tested using a short access token I get using JS API and posting with that works, but short access token are not a solution

Is the information in the image, about the token that it never expires true? How can I get such a token using the http API and curl(no SDKs)


I found the issue, it was the access_token , I know it makes no sense that it worked without the link parameter but with the link parameter did not worked, but this is the truth. So you need to make sure you get the page access_token , you get that from me/accounts or with your SDK. The conclusion is that the Facebook developers are doing a bad job, wrong error messages, and allowing to post with wrong token.

链接地址: http://www.djcxy.com/p/85556.html

上一篇: 如何在新的JavaFx错误跟踪器中找到错误

下一篇: 错误张贴消息与链接到Facebook