0

尝试使用图形 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;

?>

提示帮助将不胜感激。谢谢!

4

1 回答 1

0

您可以尝试以下方法:

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

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

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

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

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

于 2013-10-25T15:04:37.923 回答