在PHP中,我试图使用图表api发布状态到我们的Facebook粉丝页面,尽管下面的facebook给出的信息,下面的代码似乎并没有更新状态。通过Facebook的图表发布状态api
这是代码;
$xPost['access_token'] = "{key}";
$xPost['message'] = "Posting a message test.";
$ch = curl_init('https://graph.facebook.com/{page_id}/feed');
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xPost);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_CAINFO, NULL);
curl_setopt($ch, CURLOPT_CAPATH, NULL);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
$result = curl_exec($ch);
有没有人知道为什么这段代码不工作? access_token是正确的。
什么打印'$ result'显示? – ceejayoz 2010-05-17 16:23:31
$结果为空 – 2010-05-17 16:27:18
您的意思是使用'$ xPost ['access_token'] =“{key}”;' 而不是'$ xPost ['access_token'] =“{$ key}”;' – Jayrox 2010-06-02 23:19:01