Project

General

Profile

API - User Oauth

URL: /oauth-login/facebook/
Method: POST
Available providers: Google, Facebook, Yahoo, Apple

Code sample:

$api_id = 1;
$api_key = 'testpass';
$hostname = 'https://example.com'; // no trailing slash

# fetch data
$url = '/oauth-login/facebook/';
$post_data = array(
    'token' => array(
        'access_token' => 'xxx'
    )
);
$user_token = 'xxx'; // is required here. Get it from Your DB after Token generation
$extra_headers = array(
    'X-API-ID: ' . $api_id,
    'X-API-Hash: ' . md5($api_key . $url. http_build_query($post_data)),
    'X-User-Token: ' . $user_token
);

header('Content-Type: application/json; charset=utf-8');
echo sendRequest($hostname . $url, $post_data, $extra_headers);

Succes message: request_message contains the customer ID

{
    has_error: false,
    messages: [],
    results: {
        request_status: "ok",
        request_message: "1234" 
    }
}

Error message :

{
    has_error: true,
    messages: [
        "Signed API request to https://graph.facebook.com/v8.0/me has returned an error. HTTP error 401. Raw Provider API response: {"error":{"message":"Invalid OAuth access token.","type":"OAuthException","code":190,"fbtrace_id":"AEF6IKiQbGV9z5WPbD96i0f"}}." 
    ],
    results: [ ]
}

Go to top