我使用基于#unificationengine API的以下curl代码访问facebook图形api并在facebook上发布消息:
$post_msg = json_encode(
array(
'message' =>
array(
'receivers' =>
array(
array(
'name' => 'Me',
'address' => 'https://graph.facebook.com/v2.5/7/feed?access_token='.$request->access_token,
'Connector' => 'facebook'
),
),
'sender' =>
array('address' => 'sender address'),
'subject' => 'Hello',
'parts' =>
array(
array(
'id' => '1',
'contentType' => 'text/plain',
'data' => 'Hi welcome to UE',
'size' => 100,
'sort' => 0
),
),
),
)
);
$ch = curl_init('https://apiv2.unificationengine.com/v2/message/send');
curl_setopt($ch, CURLOPT_USERPWD, "ab33333222b-acb5-49a6-a766-80d991daff41:43433232-33cb-49f0-3333-3fe6c46acb5f");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_msg);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// execute!
$response = curl_exec($ch);
// close the connection, release resources used
curl_close($ch);
// do anything you want with your response
var_dump($response);
return ['label' =>$response];代码498的访问令牌错误无效。我参考了许多关于这个话题的帖子,但不知道缺少了什么。
如何检查facebook访问令牌的有效性。
参考了以下问题:
发布于 2017-01-07 09:27:23
facebook访问令牌的生命周期约为两个小时。对于更长寿的web应用程序,特别是服务器端,需要生成长寿命的令牌。长寿的代币一般持续60天左右。
UE具有刷新facebook令牌的能力。在使用"apiv2.unificationengine.com/v2/connection/add";api调用添加连接之后,您应该调用"apiv2.unificationengine.com/v2/connection/refresh";api来使短寿命令牌变为长寿命令牌。
https://stackoverflow.com/questions/41505014
复制相似问题