未捕获OAuthException:(#100)使用图形api在facebook中创建事件时抛出的参数无效

时间:2013-10-25 14:10:15

标签: php facebook-graph-api

尝试使用图形api

创建事件时,我遇到了以下错误

致命错误:未捕获OAuthException:(#100)第1267行的C:\ xampp \ htdocs \ fb \ base_facebook.php中抛出的参数无效

任何人都可以帮我这个。

以下是我的代码: -

<?php

include_once("facebook.php");

define("FACEBOOOK_API_KEY","XXXXXXXXXXXXXXXXXXXXX");
define("FACEBOOK_SECRET_KEY","XXXXXXXXXXXXXXXXXXXXXXXX");

/*$name = $_POST['name'];
$token = $_POST['access_token'];
$startTime = $_POST['start_time'];
$endTime = $_POST['end_time'];
$location = $_POST['location'];
$description = $_POST['description'];*/

$name = "My Amazing Event";
$token = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx';
$startTime = '10/29/2011 12:00 PM';
$endTime = '10/29/2011 06:00 PM';
$location = 'Raipur';
$description = 'It will be freaking awesome';

$fileName = "tiger.jpg"; //profile picture of the event

$fb = new Facebook(array(
    'appId'      => FACEBOOOK_API_KEY,
    'secret'     => FACEBOOK_SECRET_KEY,
    'cookie'     => false,
    'fileUpload' => true     // this is important !
));

$fb->setAccessToken($token);

$data = array("name"=>$name,
              "access_token"=>$token,
              "start_time"=>$startTime,
              "end_time"=>$endTime,
              "location"=>$location,
              "description"=>$description
              //basename($fileName) => '@'.$fileName
);

$post_data[basename($fileName)] = '@' . realpath($fileName);

    $result = $fb->api('/me/events', 'POST', $data);
    $facebookEventId = $result['id'];
    echo $facebookEventId;

?>

非常感谢提示帮助。谢谢!!!

1 个答案:

答案 0 :(得分:0)

您可以尝试以下方法:

  1. 使用https://developers.facebook.com/docs/reference/api/user/#events所述的正确日期/时间格式(仅限日期(例如,'2012-07-04')/精确时间(例如,'2012-07-04T19: 00:00-0700' ))

  2. 将access_token从$ data放入调用url:

    fb->api('/me/events?access_token=YOURTOKEN', 'POST', $data);

  3. 尝试使用您的profileID而不是'我'

    fb->api('/YOURPROFILEID/events?access_token=YOURTOKEN', 'POST', $data);