Skip to content

Commit

Permalink
Proxy testing
Browse files Browse the repository at this point in the history
  • Loading branch information
nathancox committed Jan 9, 2019
1 parent 9cd96df commit bb4e30b
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions src/Providers/SocialFeedProviderFacebook.php
Expand Up @@ -79,29 +79,30 @@ public function getType()

public function getFeedUncached()
{
$providerOptions = [
'clientId' => $this->FacebookAppID,
'clientSecret' => $this->FacebookAppSecret,
// https://github.com/thephpleague/oauth2-facebook#graph-api-version
'graphApiVersion' => 'v2.6'
];

info(\SilverStripe\Core\Environment::getEnv('SS_OUTBOUND_PROXY'), 'proxy');

if (\SilverStripe\Core\Environment::getEnv('SS_OUTBOUND_PROXY')) {
$providerOptions['proxy'] = sprintf('%s:%s', \SilverStripe\Core\Environment::getEnv('SS_OUTBOUND_PROXY'), \SilverStripe\Core\Environment::getEnv('SS_OUTBOUND_PROXY_PORT'));
}

if (isset($_GET['feedtest'])) {
info($providerOptions);
die;
// temporary check to toggle setting the proxy on and off so we can see where we can make it work
if (isset($_GET['feedtest']) && $_GET['feedtest'] == 2) {
$proxy = null;
if (Environment::getEnv('SS_OUTBOUND_PROXY')) {
$proxy = sprintf('%s:%s', Environment::getEnv('SS_OUTBOUND_PROXY'), Environment::getEnv('SS_OUTBOUND_PROXY_PORT'));
}

$provider = new Facebook([
'clientId' => $this->FacebookAppID,
'clientSecret' => $this->FacebookAppSecret,
// https://github.com/thephpleague/oauth2-facebook#graph-api-version [^]
'graphApiVersion' => 'v2.6',
'proxy' => $proxy
]);

} else {
$provider = new Facebook([
'clientId' => $this->FacebookAppID,
'clientSecret' => $this->FacebookAppSecret,
// https://github.com/thephpleague/oauth2-facebook#graph-api-version [^]
'graphApiVersion' => 'v2.6'
]);
}




$provider = new Facebook($providerOptions);

// For an App Access Token we can just use our App ID and App Secret pipped together
// https://developers.facebook.com/docs/facebook-login/access-tokens#apptokens
$accessToken = ($this->AccessToken) ? $this->AccessToken : $this->siteConfig->SocialFeedFacebookAppID . '|' . $this->siteConfig->SocialFeedFacebookAppSecret;
Expand Down

0 comments on commit bb4e30b

Please sign in to comment.