1. Go to this page and download the library: Download gajus/fuss library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
gajus / fuss example snippets
/**
* @param int $app_id App ID.
* @param string $app_secret App secret.
*/
$app = new Gajus\Fuss\App(123, 'abc');
$user = null;
$signed_request = $app->getSignedRequest();
if ($signed_request) {
$access_token = $signed_request->getAccessToken();
if ($access_token) {
if (!$access_token->isLong()) {
$access_token->extend();
}
$user = new Gajus\Fuss\User($access_token);
}
}
if ($user) {
$request = new Gajus\Fuss\Request($user, 'GET', 'me', ['fields' => 'first_name']);
$response = $request->make();
// $response['first_name']
}
/**
* Designed to be used for a signed request retrieved via the JavaScript SDK.
*
* @see https://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus#response_and_session_objects
* @param string $signed_request
* @return null
*/
$app->setSignedRequest('the signed request');
/**
* User ID when user access token is in or can be derived from the signed request.
*
* @return null|int
*/
$signed_request->getUserId();
/**
* The content of the app_data query string parameter which may be passed if the app is being loaded within a Page Tab.
* The JSON input is automatically decoded.
*
* @see https://developers.facebook.com/docs/reference/login/signed-request/
* @return mixed
*/
$signed_request->getAppData();
/**
* Return the signed request payload.
*
* @see https://developers.facebook.com/docs/reference/login/signed-request/
* @return array
*/
$signed_request->getPayload();
/**
* Resolve the user access token from the signed request.
* The access token is either provided or it can be exchanged for the code.
*
* @return null|Gajus\Fuss\AccessToken
*/
$access_token = $signed_request->getAccessToken();
/**
* @param Gajus\Fuss\App $app
* @param string $access_token A string that identifies a user, app, or page and can be used by the app to make graph API calls.
* @param self::TYPE_USER|self::TYPE_APP|self::TYPE_PAGE $type
*/
$access_token = new Gajus\Fuss\AccessToken($app, 'user access token', Gajus\Fuss\AccessToken::TYPE_USER);
/**
* The issued_at field is not returned for short-lived access tokens.
*
* @see https://developers.facebook.com/docs/facebook-login/access-tokens#debug
* @return boolean
*/
$access_token->isLong();
/**
* Extend a short-lived access token for a long-lived access token.
* Upon successfully extending the token, the instance of the object
* is updated with the long-lived access token.
*
* @see https://developers.facebook.com/docs/facebook-login/access-tokens#extending
* @return null
*/
$access_token->extend();
/**
* @return int UNIX timestamp in seconds.
*/
$access_token->getExpirationTimestamp();
/**
* @return string The access token as a string.
*/
$access_token->getPlain();
/**
* @param Gajus\Fuss\AccessToken $access_token
*/
$user = new Gajus\Fuss\User($access_token);
/**
* Get Facebook user ID.
* Beware that as of Graph API v2.0, the user ID is app-scoped.
*
* @see https://developers.facebook.com/docs/apps/upgrading#upgrading_v2_0_user_ids
* @return null|int
*/
$user->getId();
/**
* @param Gajus\Fuss\Session $session
* @param string $method GET|POST|DELETE
* @param string $path Path relative to the Graph API.
* @param array $query GET parameters.
*/
$request = new Gajus\Fuss\Request($app, 'GET', 'app');
/**
* @throws Gajus\Fuss\RequestException If the Graph API call results in an error.
* @return array Graph API response.
*/
$request->make();
/**
* Return PageTab when app is loaded in a page tab.
*
* @return null|Gajus\Fuss\PageTab
*/
$page_tab = $signed_request->getPageTab();
/**
* The page ID.
*
* @return int
*/
$page_tab->getId();
/**
* true if the loading user has liked the page, false if not.
*
* @deprecated This field will no longer be .
*
* @return boolean
*/
$page_tab->isAdmin();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.