错误107解析REST API的无效日期

时间:2014-12-25 19:43:47

标签: rest facebook-graph-api curl parse-platform datetime-format

我正在尝试使用解析REST API对facebook用户进行身份验证,但是在通过CURL发送json之后,它给出了以下错误消息:

{  
   "code":107,
   "error":"Invalid date"
}

文档说明了以下关于必须发送的json中的expiration_date格式:

{
  "facebook": {
    "id": "user's Facebook id number as a string",
    "access_token": "an authorized Facebook access token for the user",
    "expiration_date": "token expiration date of the format: yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
  }
}

以下是我用于将日期设置为我认为解析所需的ISO8601格式的代码:

$session = $helper->getSessionFromRedirect();
$request = new FacebookRequest( $session, 'GET', '/me' );
$response = $request->execute();
$graphObject = $response->getGraphObject();
$token = $session->getToken();
$info = $session->getSessionInfo();
$expiresAt = $info->getExpiresAt();
$expiresAtFormatted = $expiresAt->format(\DateTime::ISO8601);

$facebook = array(
    'authData' => array(
        'facebook' => array(
            'id' => $id,
            'access_token' => $token,
            'expiration_date' => $expiresAtFormatted
        )
    )
);
$facebookJson = json_encode($facebook);

以下是var_dump变量的$expiresAtFormatted

string(24) "2015-02-23T18:17:59+0000"

0 个答案:

没有答案