0

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 !

Edited by pritaeas: Removed API credentials.

2
Contributors
4
Replies
19
Views
2 Years
Discussion Span
Last Post by Hilal2009
0

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.

0

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

Edited by Hilal2009

Attachments error.JPG 93.48 KB Capture.JPG 40.74 KB
1

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 
0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.