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
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.