【问题标题】:Create event in facebook page在 Facebook 页面创建活动
【发布时间】:2013-02-02 09:15:09
【问题描述】:

我正在尝试通过 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);

【问题讨论】:

    标签: php facebook facebook-graph-api


    【解决方案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();
    }
    

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-02-28
        • 2014-06-22
        • 1970-01-01
        • 2023-03-28
        • 2011-11-25
        • 1970-01-01
        • 1970-01-01
        • 2011-10-26
        相关资源
        最近更新 更多