PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, February 11, 2022

[FIXED] facebook graph api getGraphObject()->asArray() returns null

 February 11, 2022     facebook-php-sdk, php     No comments   

Issue

so I have this:

$pages = (new FacebookRequest($session, 'GET', '/search?q=Computers/Technology&fields=likes'))->execute()->getGraphObject()->asArray();

I just want to get the likes of those pages, so I did $pages["likes"] also tried $pages->likes and I get null. But when i do var_dump($pages) it shows all the data. So why can't I get just the likes?


Solution

Depending on what var_dump($pages) returns, you may need to do something like $pages[''][''] to get to the likes. I'm not sure since you didn't include that.

If the value isn't undefined and you can actually see the data using var_dump, you shouldn't have any problem getting to the specific fields once you understand the structure. Try

print_r($pages)

as well to see your info. Also, as long as there's no sensitive data, post the output or a sample of the output to help us with out answers.

Cheers!



Answered By - Tim Lewis
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing