本文整理汇总了PHP中Facebook\FacebookSession::_getTargetAppSecret方法的典型用法代码示例。如果您正苦于以下问题:PHP FacebookSession::_getTargetAppSecret方法的具体用法?PHP FacebookSession::_getTargetAppSecret怎么用?PHP FacebookSession::_getTargetAppSecret使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Facebook\FacebookSession
的用法示例。
在下文中一共展示了FacebookSession::_getTargetAppSecret方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAccessToken
/**
* @param $code
* @return null
* @throws \Facebook\FacebookRequestException
* @throws \Facebook\FacebookSDKException
*/
protected function getAccessToken($code)
{
$response = (new FacebookRequest(FacebookSession::newAppSession(), 'GET', '/oauth/access_token', ['client_id' => FacebookSession::_getTargetAppId(), 'client_secret' => FacebookSession::_getTargetAppSecret(), 'redirect_uri' => Config::get('auth.providers.facebook.redirect_uri'), 'code' => $code]))->execute()->getResponse();
// Graph v2.3 and greater return objects on the /oauth/access_token endpoint
$accessToken = null;
if (is_object($response) && isset($response->access_token)) {
$accessToken = $response->access_token;
} elseif (is_array($response) && isset($response['access_token'])) {
$accessToken = $response['access_token'];
}
return $accessToken;
}
示例2: __construct
/**
* @param FacebookSession $session A Facebook API session
* @param LoggerInterface $logger A PSR-3 compatible logger
*/
public function __construct(FacebookSession $session, LoggerInterface $logger = null)
{
$this->session = $session;
$this->logger = $logger ?: new NullLogger();
if (static::instance() === null) {
static::setInstance($this);
}
try {
FacebookSession::_getTargetAppSecret();
} catch (FacebookSDKException $f) {
// Disable sending app secret proof and warn
FacebookSession::enableAppSecretProof(false);
trigger_error('You should set a default app id and secret, see the README.md file ' . 'for more information.', E_USER_DEPRECATED);
}
}
示例3: __construct
/**
* Initialize the helper and process available signed request data.
*
* @param string|null $appId
* @param string|null $appSecret
*/
public function __construct($appId = null, $appSecret = null)
{
$this->appId = FacebookSession::_getTargetAppId($appId);
$this->appSecret = FacebookSession::_getTargetAppSecret($appSecret);
$this->instantiateSignedRequest();
}
示例4: getAppSecretProof
/**
* Generate and return the appsecret_proof value for an access_token
*
* @param string $token
*
* @return string
*/
public function getAppSecretProof($token)
{
return hash_hmac('sha256', $token, FacebookSession::_getTargetAppSecret());
}
示例5: hashSignature
/**
* Hashes the signature used in a signed request.
*
* @param string $encodedData
* @param string|null $appSecret
*
* @return string
*
* @throws FacebookSDKException
*/
public static function hashSignature($encodedData, $appSecret = null)
{
$hashedSig = hash_hmac('sha256', $encodedData, FacebookSession::_getTargetAppSecret($appSecret), $raw_output = true);
if ($hashedSig) {
return $hashedSig;
}
throw new FacebookSDKException('Unable to hash signature from encoded payload data.', 602);
}
示例6: request
/**
* Send a request to Graph with an app access token.
*
* @param string $endpoint
* @param array $params
* @param string|null $appId
* @param string|null $appSecret
*
* @return \Facebook\FacebookResponse
*
* @throws FacebookRequestException
*/
protected static function request($endpoint, array $params, $appId = null, $appSecret = null)
{
$targetAppId = FacebookSession::_getTargetAppId($appId);
$targetAppSecret = FacebookSession::_getTargetAppSecret($appSecret);
if (!isset($params['client_id'])) {
$params['client_id'] = $targetAppId;
}
if (!isset($params['client_secret'])) {
$params['client_secret'] = $targetAppSecret;
}
// The response for this endpoint is not JSON, so it must be handled
// differently, not as a GraphObject.
$request = new FacebookRequest(FacebookSession::newAppSession($targetAppId, $targetAppSecret), 'GET', $endpoint, $params);
return $request->execute();
}
示例7: __construct
/**
* Constructs a RedirectLoginHelper for a given appId.
*
* @param string $appId The application id
* @param string $appSecret The application secret
*/
public function __construct($appId = null, $appSecret = null)
{
$this->appId = FacebookSession::_getTargetAppId($appId);
$this->appSecret = FacebookSession::_getTargetAppSecret($appSecret);
}
示例8: fbAuthAction
public function fbAuthAction()
{
$this->view->disable();
$params = array('client_id' => FacebookSession::_getTargetAppId($this->config->facebook->appId), 'redirect_uri' => $this->config->facebook->redirect, 'client_secret' => FacebookSession::_getTargetAppSecret($this->config->facebook->secret), 'code' => isset($_GET['code']) ? $_GET['code'] : null);
$response = (new FacebookRequest(FacebookSession::newAppSession($this->config->facebook->appId, $this->config->facebook->secret), 'GET', '/oauth/access_token', $params))->execute()->getResponse();
if (isset($response['access_token'])) {
$session = new FacebookSession($response['access_token']);
}
if (isset($session)) {
$userSession['access_token'] = $response['access_token'];
$request = new FacebookRequest($session, 'GET', '/me');
$response = $request->execute();
// get response
$graphObject = $response->getGraphObject();
$email = $graphObject->getProperty('email');
$fbId = $graphObject->getProperty('id');
$verified = $graphObject->getProperty('verified');
$firstName = $graphObject->getProperty('first_name');
$lastName = $graphObject->getProperty('last_name');
$fullName = $graphObject->getProperty('name');
$gender = $graphObject->getProperty('gender');
$profileLink = $graphObject->getProperty('link');
$bday = $graphObject->getProperty('birthday');
$email = $graphObject->getProperty('email');
$city = $graphObject->getProperty('location')->getProperty('name');
if (!isset($email)) {
$email = $fbId . '@facebook.com';
}
if (isset($bday)) {
$bday = date('Y-m-d', strtotime($bday));
}
$socialData = array('social_network' => 'Facebook', 'social_id' => $fbId, 'first_name' => $firstName, 'last_name' => $lastName, 'full_name' => $fullName, 'gender' => $gender, 'profile_link' => $profileLink, 'birthday' => $bday, 'email' => $email, 'city' => $city, 'access_token' => $userSession['access_token']);
if ($member = Members::findFirstByEmail($email)) {
$userSession = get_object_vars($member);
if (!($socialProfile = SocialProfiles::findFirstByEmail($email))) {
$socialData['member_id'] = $member->id;
$this->newSocialProfile($socialData);
}
} else {
$memberId = $this->newMember($socialData);
$socialData['id'] = $memberId;
$userSession = $socialData;
$socialData['member_id'] = $memberId;
$this->newSocialProfile($socialData);
}
//print_r($graphObject);
$this->session->set('userSession', $userSession);
}
return $this->response->redirect();
}