1

我正在尝试使用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'];
4

1 回答 1

0

异常告诉自己错误是位置 ID 的错误值。正如您自己调试过的那样,这是因为您将其检索为

$event_location_id = $event_location['id'];

哪个应该被检索为

$event_location_id= $event_location['location']['id'];
于 2013-05-03T08:51:35.090 回答