我正在尝试通过cron-job创建facebook事件。这些事件应该是代表我的facebook-connect-site的用户创建的,他们已经被授予了离线访问权限。我有没有过期的session_keys,但是不能让它工作!为我的应用程序创建活动就像是一种魅力,这不是我想要的……
var_dump($event) with some randomly generated data:
'name' => string 'Try a athirst these and' (length=23)
'tagline' => string 'as it that he down the almost the' (length=33)
'description' => string 'that deeper but is sea whenever lead all a stream knowing robust bakehouses attending have am it pent for own quick' (length=115)
'category' => int 5
'subcategory' => int 52
'location' => string 'same as more the' (length=16)
'start_time' => int 1263630600
'end_time' => int 1263654000
'street' => string 'This Was Ships My 807' (length=21)
'phone' => string '49 692 324' (length=10)
'email' => string 'oeott@yahoo.com' (length=15)
'privacy_type' => string 'OPEN' (length=4)
<?php
$facebook = new Fb(FACEBOOK_API_KEY, FACEBOOK_API_SECRET);
// Set session key (that has been returned after offline-access has been granted)
$facebook->api_client->session_key = '5de03e54cb359f9asf3435365e-4588985454';
$eid = $facebook->api_client->events_create(json_encode($event));
?>
结果为:“异常'FacebookRestClientException‘,消息为'Invalid parameter'”
有谁能拯救我的一天吗?
发布于 2011-01-26 05:12:40
假设您已经请求了create_events扩展权限,那么您应该能够使用新的Open Graph API和最新的PHP SDK来执行此操作。代码应该是这样的(未经过测试):
$facebook = new Facebook(array(
'appId' => 'application ID',
'secret' => 'application secret',
'cookie' => true,
));
if ($session = $facebook->getSession()) {
try {
$event = $facebook->api("/me/events","post",array(
'title'=>'My Event Name',
'start_time'=>1263630600,
'end_time'=>1263654000,
// etc add your other event info here
));
} catch (FacebookApiException $e) {
error_log($e);
}
}
它也应该作为CRON任务运行,我不知道为什么它不会。
发布于 2011-02-11 19:07:13
您确定需要使用会话密钥吗?我一直在使用access_token,它是在授予向墙上张贴项目和离线访问用户信息的访问权限时提供的。
编辑:代码示例,非常适合我将项目发布到用户墙(事件的工作方式类似):
<?php
$ch = curl_init ('https://graph.facebook.com/me/feed');
curl_setopt ($ch, CURLOPT_POST, true);
curl_setopt ($ch, CURLOPT_POSTFIELDS, array('access_token' => $user_access_token, 'message' => $message, 'link' => $link));
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
$ret = curl_exec ($ch);
$ret = json_decode($ret);
if (!empty($ret->id)) {
return true;
}
return false;
https://stackoverflow.com/questions/2070072
复制相似问题