在Facebook页面中创建活动

时间:2013-02-02 09:15:10

标签: php facebook facebook-graph-api

我正在尝试通过Facebook页面创建活动。我已经给出了页面id和create_event权限。然而,我的活动没有发布。我一直得到这个

        [message] => (#100) Invalid parameter
                [type] => OAuthException
                [code] => 100

我正在使用在这些论坛中发布的以下编码

    $page_id='xxxxx';
    $event_info = array( 
    'name' => 'abc event', 
    'description' => 'hi dis s an event', 
    'owner' => 'eric example', 
    'location' => 'Location name and street', 
    'city' => 'chennai', 
    'start_time' => date('Y-m-d H:i', time()), 
    'privacy_type' => 'OPEN' ); 

     $event_id = $facebook->api('/'.$page_id.'/events', 'post', $event_info);

2 个答案:

答案 0 :(得分:1)

我想通了......我在指定时间时犯了一个错误

$page_id = $_SESSION['xxxxx'];
$pid='xxxxxxx';

// Now, getting the PAGE Access token, using the user access token

 $page_token_url = "https://graph.facebook.com/$page_id?fields=access_token&" .       $access_token;
 $response = file_get_contents($page_token_url);

// Parse the return value and get the Page access token
$resp_obj = json_decode($response,true);

$page_access_token = $resp_obj['access_token'];

$event_param = array(
    'name' => 'abc event', 
    'description' => 'hi dis s an event', 
    'owner' => ' example', 
    'location' => 'Location name and street', 
    'city' => 'chennai', 
    'start_time' => '2013-12-31T13:45:00+0100', 
    'privacy_type' => 'OPEN' ,
'page_id'       => $pid
);

try
{
    $fb_event_id = $facebook->api('/'.$pid.'/events?access_token=ACCESS_TOKEN', "POST", $event_param);
}
catch (FacebookApiException $e)
{
    echo $e->getMessage();
}

答案 1 :(得分:-1)

请使用此格式并提供访问令牌以便在页面上发布

$data = array(
          "name"=>$event_name,
          "access_token"=>$fb_oauth_token,
          "start_time"=>"2014-07-04",
          "end_time"=>"2014-07-06",
          "location"=>"$location",
          "description"=>"hello"
        );