[] [] [] [] []
Adds a link to the Silverstripe SiteConfig that prompts login from the User. Once logged in, an Auth Token is generated that is automatically extended to have a Long Access Period. This token can then be accessed by custom code for use in generating social feeds.
A 'Manual Override' feature has been added to allow manual setting of an access token if required.
composer require internetrix/silverstripe-facebook
This module requires the domain to be using HTTPS, as per Facebook's security requirements. You will also need to add the following domain (replaced with your details) to the Valid OAuth Redirect URIs in the App Settings:
https://{yourdomain}/facebook/login
e.g. https://local.com/facebook/login
Please include the following config to a .yml file to enable the connection:
Internetrix\Facebook\Config:
facebook_public_token: 'your-public-token-here'
facebook_secret_token: 'your-secret-token-here'
You can access the token for your projects via the following:
$siteConfig = SiteConfig::current_site_config();
/** @var AccessToken $accessToken */
$accessToken = unserialize($siteConfig->FacebookAccessToken);
if ($accessToken && is_a($accessToken, AccessToken::class)) {
$accessToken = $accessToken->getValue();
}
Or with the following if you implement the FacebookHelperTrait
:
$this->getSiteAccessToken();