Here are my codes, I want to get access token after user login, but I don't know where am I wrong guys.
I know to get access token in PHP SDK v4 but I think It's quite different in PHP SDK v5. Please help me
guys

<?php
    session_start();
    require_once("Facebook/autoload.php");        
    use Facebook\Facebook;
    use Facebook\FacebookResponse;
    use Facebook\GraphNodes\GraphNode;
    use Facebook\Helpers\FacebookRedirectLoginHelper;
    use Facebook\Exceptions\FacebookSDKException;
    use Facebook\Exceptions\FacebookResponseException;

    $api_id="1";
    $api_secret="2";
    $url="http://localhost:80/feedreader/fdposter.php";

    $fb = new Facebook([
      "app_id" => $api_id,
      "app_secret" => $api_secret,
      "default_graph_version" => "v2.2",
      ]);  

    $helper=$fb->getRedirectLoginHelper();    
    try{
        $token=$helper->getAccessToken();        
        if(isset($token))
        {            
            echo "Successfully......";
        }        
        else{
            $permision=array("scope"=>"email");
            echo "<a href='".$helper->getLoginUrl($url,$permision)."'>Click to post</a>";            
        }
    } 
    catch (Facebook\Exceptions\FacebookSDKException $e) 
    {
        echo $e->getMessage();
    }
?>

Below is the message that I get after running the code
error.JPG !

The error message suggests to enable the web OAuth login, so go to your Facebook App dashboard > Settings > Advanced, scroll to Client OAuth Settings and set Web OAuth Login to Yes, then it should work.

The error message suggests to enable the web OAuth login, so go to your Facebook App dashboard > Settings > Advanced, scroll to Client OAuth Settings and set Web OAuth Login to Yes, then it should work.

Refer to the picture below, these are my settings together with the error that I get from what you have said

Ok, the URI registered in your script and in your App defines the port number:

http://localhost:80/feedreader/fdposter.php

But in your browser (screenshot) the port number is missing:

http://localhost/feedreader/fdposter.php

If you're using port 80, then try to remove it from the App settings and from the script, as this is an implicit port number and could generate this kind of problems.

In other words, set the redirect URI in App settings and in your script to:

http://localhost/feedreader/fdposter.php

Ok, the URI registered in your script and in your App defines the port number:

http://localhost:80/feedreader/fdposter.php
But in your browser (screenshot) the port number is missing:

http://localhost/feedreader/fdposter.php
If you're using port 80, then try to remove it from the App settings and from the script, as this is an implicit port number and could generate this kind of problems.

In other words, set the redirect URI in App settings and in your script to:

http://localhost/feedreader/fdposter.php

Greate!!!!!!!!! Thank you somuch cereal, I appreciate you

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.