Facebook login on symfony with sdk 5

Hi guys i need your help, i installed facebook sdk with composer on my application, y created a login system, on facebook developer i added my dev domain on localhost https://devlocalhost.io and my domain from production, so in localhost the loging is working fine, but on production i get this error

Argument 3 passed to GuzzleHttpClient::request() must be of the type array,   string given, called in /home/user/src/app/vendor/guzzlehttp/guzzle/src/Client.php on line 89

here is part of my code,
on my SecurityController

 public function facebookCallback(Request $request,UserPasswordEncoderInterface $encoder)
{

    $fb = $this->facebook();
    $helper = $this->fHelper($fb);

    try {
        $accessToken = $helper->getAccessToken();
    } catch(FacebookExceptionsFacebookResponseException $e) {
        // When Graph returns an error
        echo 'Graph returned an error: ' . $e->getMessage();
        exit;
    } catch(FacebookExceptionsFacebookSDKException $e) {
        // When validation fails or other local issues
        echo 'Facebook SDK returned an error: ' . $e->getMessage();
        exit;
    }

    if (! isset($accessToken)) {
        if ($helper->getError()) {
            header('HTTP/1.0 401 Unauthorized');
            echo "Error: " . $helper->getError() . "n";
            echo "Error Code: " . $helper->getErrorCode() . "n";
            echo "Error Reason: " . $helper->getErrorReason() . "n";
            echo "Error Description: " . $helper->getErrorDescription() . "n";
        } else {
            header('HTTP/1.0 400 Bad Request');
            echo 'Bad request';
        }
        exit;
    }

    // Logged in


    try {
        // Returns a `FacebookFacebookResponse` object
        $response = $fb->get('/me?fields=id,name,email,link,picture', $accessToken->getValue());
    } catch(FacebookExceptionsFacebookResponseException $e) {
        echo 'Graph returned an error: ' . $e->getMessage();
        exit;
    } catch(FacebookExceptionsFacebookSDKException $e) {
        echo 'Facebook SDK returned an error: ' . $e->getMessage();
        exit;
    }
      $user_info = $response->getGraphUser();
    //here i create the user on my app or check if the user exist

    }

So, here are my private method to the Facebook object and helper

private function facebook()
{

    $fb = new Facebook([
        'app_id' => 'myapp-id', // Replace {app-id} with your app id
        'app_secret' => 'my-secret',
        'default_graph_version' => 'v3.1',
    ]);

    return $fb;
}
private function fHelper($fb)
{
    $helper = $fb->getRedirectLoginHelper();
    return $helper;
}

private function furlLogin()
{
    $fb = $this->facebook();
    $helper = $this->fHelper($fb);

    $permissions = ['email']; // Optional permissions
    //$loginUrl = $helper->getLoginUrl('https://devlocalhost.io/es/fb-callback/', $permissions);
    $loginUrl = $helper->getLoginUrl('https://my_domain.com/es/fb-callback/', $permissions);

    return $loginUrl;
}

so, on local host ys working fine but when i did the deploy os the branch i installed the dependency on server etc, is giving me this error
any idea?

Source: Symfony1 Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *