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

Friday, February 11, 2022

[FIXED] How to create public facebookRequest class ? php facebook SDK

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

Issue

I would like to get the city graph by facebook php sdk:

public static function getPublicGraphObject($Id)
{
  $request = new FacebookRequest(null, 'GET', '/'.$Id);
  $response = $request->execute();
  $graphObject = $response->getGraphObject();

  return $response->getGraphObject()->asArray();
} 

because the city is public data, there is no need for session ? unfortunately I get this error Facebook\FacebookRequest::__construct() must be an instance of Facebook\FacebookSession, null given ? what should I do ?


Solution

To initialize the FacebookRequest class, you need to pass it a FacebookSession instance as first parameter, you can not simply pass NULL instead.

If you do not have a current user logged in to your app (and therefor no user session), or want to make a request not on behalf of the current user, but simply “as” your app instead, create a new app session and pass that – the FacebookSession class has a newAppSession method for that purpose.



Answered By - CBroe
  • 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