PHP Facebook请求权限发布

When i log in on Facebook it requires me the permits. Here is the code that i use for log in and requires the permits:

<?php
session_start();
// added in v4.0.0
require_once 'autoload.php';
require 'functions.php';
use Facebook\FacebookSession;
use Facebook\FacebookRedirectLoginHelper;
use Facebook\FacebookRequest;
use Facebook\FacebookResponse;
use Facebook\FacebookSDKException;
use Facebook\FacebookRequestException;
use Facebook\FacebookAuthorizationException;
use Facebook\GraphObject;
use Facebook\Entities\AccessToken;
use Facebook\HttpClients\FacebookCurlHttpClient;
use Facebook\HttpClients\FacebookHttpable;
// init app with app id and secret
FacebookSession::setDefaultApplication( '*************','*************************' );
$required_scope     = 'public_profile, publish_actions, email, manage_pages'; //Permissions required
// login helper with redirect_uri
    $helper = new FacebookRedirectLoginHelper('http://www.bestparty.altervista.org/APP/facebook/fbconfig.php' );
try {
  $session = $helper->getSessionFromRedirect();

} catch( FacebookRequestException $ex ) {
  // When Facebook returns an error
} catch( Exception $ex ) {
  // When validation fails or other local issues
}
// see if we have a session
if ( isset( $session ) ) {
  // graph api request for user data
  $request = new FacebookRequest( $session, 'GET', '/me?$fields=access_token' );
  $response = $request->execute();
  // get response
  $graphObject = $response->getGraphObject();
        $fbid = $graphObject->getProperty('id');              // To Get Facebook ID
        $fbfullname = $graphObject->getProperty('name'); // To Get Facebook full name
        $femail = $graphObject->getProperty('email');   

    /* ---- Session Variables -----*/
        $_SESSION['FBID'] = $fbid;           
        $_SESSION['FULLNAME'] = $fbfullname;
        $_SESSION['EMAIL'] =  $femail;
         checkuser($fbid,$fbfullname,$femail);
    /* ---- header location after session ----*/


        $cookie_name = 'FBID';
        $cookie_value = $fbid;
        setcookie($cookie_name, $cookie_value, time() + (86400 * 30), '/'); 
        $cookie_name2 = 'FULLNAME';
        $cookie_value2 = $fbfullname;
        setcookie($cookie_name2, $cookie_value2, time() + (86400 * 30), '/'); 

  header("Location: ../gestaccount.php");
} else {

  $cookie_name = 'FBID';
        $cookie_value = $fbid;
        setcookie($cookie_name, $cookie_value, time() + (86400 * 30), '/'); 
  $loginUrl = $helper->getLoginUrl( array( 'scope' => $required_scope ) );

  header("Location: ".$loginUrl);
}
?>

When I try to publish a post, it doesn't work. And it gives me this error:

Fatal error: Call to a member function api() on a non-object in /membri/bestparty/APP/TRY.php on line 11

This is the code that i use to publish a post:

<?php
 require_once 'facebook/autoload.php';
 $params = array(
            'message'       =>  "your message",
            'name'          =>  "hello world",
            'description'   =>  "hello world",
            'link'          =>  "hello world",
            'picture'       =>  "hello world",
        );

        $post = $facebook->api("/$user/feed","POST",$params);

        echo "lalalal";

?>