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

Friday, February 11, 2022

[FIXED] Facebook Getting Event from PAGE! not user PHP sdk v4.0.x graph 2.1

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

Issue

im trying to just get PAGE/Event from facebook and im still in doubt about how to do it

and if im doing it right or am i totally of track?

// for permanet session
$session = new FacebookSession("permanet app token");
// If you're making app-level requests: (copy paste from facebook :P)
$session = FacebookSession::newAppSession();

// To validate the session:
try {
  $session->validate();
} catch (FacebookRequestException $ex) {
  // Session not valid, Graph API returned an exception with the reason.
  echo $ex->getMessage();
} catch (\Exception $ex) {
  // Graph API returned info, but it may mismatch the current app or have expired.
  echo $ex->getMessage();
}
if ( isset( $session ) && $session->validate() ) {
if($session) {

  try {

    $user_profile = (new FacebookRequest(
      $session, 'GET', '/PAGE/events'
    ))->execute()->getGraphObject(GraphUser::className());

    print_r($user_profile);

  } catch(FacebookRequestException $e) {

    echo "Exception occured, code: " . $e->getCode();
    echo " with message: " . $e->getMessage();

  }   

}

so im wondering is this wrong or is it okey i just wanna post events i don't wanna login and stuff like that

im sorry im not good at english or explaining, so if something is unclear please let me know and i will try to explain as best as i can!


Solution

If you just want to get public events from a page, when what you are doing is correct. Just make sure the events on the page are public.

You cannot, however, create or post events without logging in. Firstly, the API no longer allows you to create events via the API. Secondly, viewing private events will require to login so Facebook can determine if you have permission to view the event or not.



Answered By - Niraj Shah
  • 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