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

Friday, February 11, 2022

[FIXED] wordpress page is broken when trying to connect to facebook php SDK

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

Issue

I have a strange issue when trying to connect to Facebook php SDK from my WordPress site. I have followed all instructions as shown on Facebook developers and other sites - I have an app on Facebook and I have downloaded the latest Facebook SDK.

session_start();
require_once(ABSPATH . 'facebook-php-sdk-v4-4.0-dev/src/Facebook/FacebookSession.php');
require_once(ABSPATH . 'facebook-php-sdk-v4-4.0-dev/src/Facebook/FacebookRequest.php');
require_once(ABSPATH . 'facebook-php-sdk-v4-4.0-dev/src/Facebook/FacebookResponse.php');
require_once(ABSPATH . 'facebook-php-sdk-v4-4.0-dev/src/Facebook/FacebookSDKException.php');
require_once(ABSPATH . 'facebook-php-sdk-v4-4.0-dev/src/Facebook/FacebookRequestException.php');
require_once(ABSPATH . 'facebook-php-sdk-v4-4.0-dev/src/Facebook/GraphObject.php');
require_once(ABSPATH . 'facebook-php-sdk-v4-4.0-dev/src/Facebook/FacebookRedirectLoginHelper.php');
require_once(ABSPATH . 'facebook-php-sdk-v4-4.0-dev/src/Facebook/FacebookAuthorizationException.php');
require_once(ABSPATH . 'facebook-php-sdk-v4-4.0-dev/src/Facebook/FacebookJavaScriptLoginHelper.php');

use Facebook\FacebookSession;
use Facebook\FacebookJavaScriptLoginHelper;
use Facebook\FacebookRedirectLoginHelper;
use Facebook\FacebookRequest;
use Facebook\FacebookResponse;
use Facebook\FacebookSDKException;
use Facebook\FacebookRequestException;
use Facebook\FacebookAuthorizationException;
use Facebook\GraphObject;

FacebookSession::setDefaultApplication('172357792955421', 'b0a5bc2aeb8b2a8712c0af6f01e45c1a');

$helper = new FacebookJavaScriptLoginHelper();
try {
   $session = $helper->getSession();
} catch(FacebookRequestException $ex) {
   echo 'Facebook returns an error';
} catch(\Exception $ex) {
   echo 'When validation fails or other local issues';
}
if ($session)
   echo 'logged in';
else
   echo 'not logged in';

I have also tried:

require_once( ABSPATH . 'facebook-php-sdk-v4-4.0-dev/autoload.php' );

instead of requiring each single php.

The problem is that the page is broken - cut off, with no header and side tab (php error). I dont see any errors or warnings. if I make some of the require_once as comments (with //), then the page is not cut (but then of course this doesn't work).

I guess something in WordPress is doing the problem, but I can't figure out what it is. Appreciate any help with this.

Thanks

UPDATE: I get this php error: on line 3 Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /hermes/bosnaweb03b/b2442/ipg.ibetyouinfo/facebook-php-sdk-v4-4.0-dev/src/Facebook/FacebookResponse.php on line 137

so the problem is in the facebook php files? how can I fix that?


Solution

The Facebook PHP SDK v4.0 requires PHP version 5.4 or greater. That error message suggests you're using an earlier version of PHP.



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

1,259,751

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 © 2025 PHPFixing