我正在尝试使用我从当前位置检索到的location_id
作为Facebook事件创建的参数,这是我的代码:
我已经设置了所有授权令牌和扩展权限,它确实返回了有效的位置ID;但是,在我将location_id
插入事件创建参数数组后,它没有创建事件。 (所有其他字段都是通过表格设置的。)有人可以帮忙吗?
这是我的代码:
try{
//default location
$event_url = $my_url . 'create_group.php';
$event_location = $facebook->api('/me?fields=location');
$event_location_id = $event_location['id'];
echo $event_location_id;
}
catch(Exception $e)
{
echo $e;
}
$params= array(
"name" => "[Study Group]".$_POST['name'],
"description" => $_POST['description'],
"location_id" => $event_location_id,
"start_time" => $_POST['start_time'].$_POST['time_zone'],
"privacy_type" => $_POST['privacy_type'],
"end_time" => $_POST['end_time'].$_POST['time_zone']
);
以下是我的例外情况:
Exception: The place or event you attempted to plan to attend is invalid. Please try a different place or event.
异常通过以下方式解决: 改变:
$event_location_id = $event_location['id'];
到
$event_location_id= $event_location['location']['id'];
答案 0 :(得分:0)
异常告诉自己错误是Location Id的错误值。 正如你自己调试的那样,这是因为你将其检索为
$event_location_id = $event_location['id'];
应该将其检索为
$event_location_id= $event_location['location']['id'];