I was following a tutorial by codeNmind on Youtube about Facebook SDK V4. I've followed everything, but I keep getting the error that Fatal error: Class 'Facebook\FacebookSignedRequestFromInputHelper' not found in... Anyone with an idea what that could be? And if there is another tutorial you can recommend for posting on Facebook wall from my website using PHP SDK v4, please let me know.

I can't tell you exactly what went wrong. However, is this the same SDK V4 you are following?

can you show us your codes?

Normally, the page that will be running the facebook api will have codes like this

<?php
require_once('autoload.php');
use Facebook\FacebookSession;
use Facebook\FacebookRequest;
use Facebook\GraphUser;
use Facebook\FacebookRequestException;

FacebookSession::setDefaultApplication('YOUR_APP_ID','YOUR_APP_SECRET');

// Use one of the helper classes to get a FacebookSession object.
//   FacebookRedirectLoginHelper
//   FacebookCanvasLoginHelper
//   FacebookJavaScriptLoginHelper
// or create a FacebookSession with a valid access token:
$session = new FacebookSession('access-token-here');

// Get the GraphUser object for the current user:

try {
  $me = (new FacebookRequest(
    $session, 'GET', '/me'
  ))->execute()->getGraphObject(GraphUser::className());
  echo $me->getName();
} catch (FacebookRequestException $e) {
  // The Graph API returned an error
} catch (\Exception $e) {
  // Some other error occurred
}

Noticed the require_once('autoload.php')? that is a requirement and part of the distribution.

<?php
session_start();

require_once( 'Facebook/HttpClients/FacebookHttpable.php' );
require_once( 'Facebook/HttpClients/FacebookCurl.php' );
require_once( 'Facebook/HttpClients/FacebookCurlHttpClient.php' );

require_once( 'Facebook/Entities/AccessToken.php' );
require_once( 'Facebook/Entities/SignedRequest.php');

require_once( 'Facebook/FacebookSession.php' );
require_once( 'Facebook/FacebookSignedRequestFromInputHelper.php');
require_once( 'Facebook/FacebookCanvasLoginHelper.php');
require_once( 'Facebook/FacebookRedirectLoginHelper.php' );
require_once( 'Facebook/FacebookRequest.php' );
require_once( 'Facebook/FacebookResponse.php' );
require_once( 'Facebook/FacebookSDKException.php' );
require_once( 'Facebook/FacebookRequestException.php' );
require_once( 'Facebook/FacebookOtherException.php' );
require_once( 'Facebook/FacebookAuthorizationException.php' );
require_once( 'Facebook/GraphObject.php' );
require_once( 'Facebook/GraphUser.php');
require_once( 'Facebook/GraphSessionInfo.php' );

use Facebook\HttpClients\FacebookHttpable;
use Facebook\HttpClients\FacebookCurl;
use Facebook\HttpClients\FacebookCurlHttpClient;

use Facebook\Entities\AccessToken;
use Facebook\Entities\SignedRequest;

use Facebook\FacebookSession;
use Facebook\FacebookSignedRequestFromInputHelper;
use Facebook\FacebookCanvasLoginHelper;
use Facebook\FacebookRedirectLoginHelper;
use Facebook\FacebookRequest;
use Facebook\FacebookResponse;
use Facebook\FacebookSDKException;
use Facebook\FacebookRequestException;
use Facebook\FacebookOtherException;
use Facebook\FacebookAuthorizationException;
use Facebook\GraphObject;
use Facebook\GraphUser;
use Facebook\GraphSessionInfo;


FacebookSession::setDefaultApplication('MY_APP_ID','MY_APP_SECRET');

$helper = new FacebookCanvasLoginHelper();

try {
    $session = $helper->getSession();
} catch (FacebookRequestException $e) {
    echo $e->getMessage();
} catch (\Exception $ex) {
    echo $e->getMessage();
}

if ($session) {
    try {

        $request = new FacebookRequest($session, 'GET', '/me');
        $response = $request->execute();
        $me = $response->getGraphObject();
        echo $me->getProperty('name');
        echo "<br>";
        echo $me->getProperty('gender');


    } catch(FacebookRequestException $e) {
        echo $e->getMessage();
    }   
} else {
    $helper = new FacebookRedirectLoginHelper('https://apps.facebook.com/tuaafrica/');
    $auth_url = $helper->getLoginUrl();
    echo "<script>window.top.location.href='".$auth_url."'</script>";
}

?>

That's the code. I use it, but simply get blank page once directed to fb.

I have the same problem. Do you know how to fix it ???

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.