Seb*_*ian 5 php session events facebook
我想通过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));
?>
Run Code Online (Sandbox Code Playgroud)
结果:"异常'FacebookRestClientException',消息'无效参数'"
有人能在那里拯救我的一天吗?
假设您已请求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);
}
}
Run Code Online (Sandbox Code Playgroud)
它也应该作为 CRON 任务运行,我不知道为什么它不会。
| 归档时间: |
|
| 查看次数: |
1258 次 |
| 最近记录: |