4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[PHP] Facebook, Graph APIからGETしたデータを扱うためには (Tips)

Last updated at Posted at 2015-02-05

昔、3系のSDKを使っていたのですが
しばらく見ないうちに4系がでていて、あたふたしてます。

https://developers.facebook.com/docs/graph-api/using-graph-api/v2.2?locale=ja_JP
/* PHP SDK v4.0.0 */
/* make the API call */
$request = new FacebookRequest(
  $session,
  'GET',
  '/me'
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
/* handle the result */

で取得した、$graphObjectは、backingData:protectedと守られているので

modify
$request = new FacebookRequest(
  $session,
  'GET',
  '/me'
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
$data = $graphObject->asArray();

として、取得する必要がありました。

asArray()

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?