本文整理汇总了PHP中Facebook\Facebook::getApp方法的典型用法代码示例。如果您正苦于以下问题:PHP Facebook::getApp方法的具体用法?PHP Facebook::getApp怎么用?PHP Facebook::getApp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Facebook\Facebook
的用法示例。
在下文中一共展示了Facebook::getApp方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTokenInfo
/**
* @param string $token
*
* @return UserProfileInterface|null
*/
protected function getTokenInfo($token)
{
try {
// Get the Facebook\GraphNodes\GraphUser object for the current user.
$response = $this->facebook->get('/me?fields=id,name,email,first_name,last_name', $token);
$user = $response->getGraphUser();
// check if we can get user identifier
if (empty($user->getId())) {
return null;
}
// do not accept tokens generated not for our application even if they are valid,
// to protect against "man in the middle" attack
$tokenMetadata = $this->facebook->getOAuth2Client()->debugToken($token);
// this is not required, but lets be sure because facebook API changes very often
$tokenMetadata->validateAppId($this->facebook->getApp()->getId());
$userProfile = new UserProfile();
$userProfile->setIdentifier($user->getId());
$userProfile->setDisplayName($user->getName());
$userProfile->setFirstName($user->getFirstName());
$userProfile->setLastName($user->getLastName());
$userProfile->setEmail($user->getEmail());
// facebook doesn't allow login with not verified email
if (!empty($user->getEmail())) {
$userProfile->setEmailVerified(true);
}
return $userProfile;
} catch (FacebookSDKException $e) {
return null;
}
}
示例2: indexAction
public function indexAction()
{
// Initialisation de Facebook
$fb = new Facebook(['app_id' => $this->getParameter('facebook.app_id'), 'app_secret' => $this->getParameter('facebook.app_secret'), 'default_graph_version' => $this->getParameter('facebook.default_graph_version'), 'default_access_token' => $this->getParameter('facebook.default_access_token')]);
// Requête sur le nombre de likes
$request = new FacebookRequest($fb->getApp(), $fb->getDefaultAccessToken(), 'GET', '/RadioGatsun', array('fields' => 'likes'));
// Extraction
$likes = $fb->getClient()->sendRequest($request)->getGraphNode()->getField('likes');
$repository = $this->getDoctrine()->getManager()->getRepository('GatsunWebsiteBundle:Publication');
$listePublications = $repository->findBy(array(), array('date' => 'desc'), 5, 0);
$listeVignettes = $this->getDoctrine()->getManager()->getRepository('GatsunWebsiteBundle:Vignette')->findAll();
$listeEmissions = $this->getDoctrine()->getManager()->getRepository('GatsunWebsiteBundle:Emission')->getNextEmissions(2);
return $this->render('GatsunWebsiteBundle:General:accueil.html.twig', array('publications' => $listePublications, 'listeVignettes' => $listeVignettes, 'listeEmissions' => $listeEmissions, 'facebookLikes' => $likes));
}
示例3: request
/**
* Perform a Facebook request
*
* @param string $action
*
* @return \Facebook\FacebookResponse|null
*/
protected function request($action)
{
if ($this->facebook === null) {
return null;
}
try {
$response = $this->facebook->get($action, $this->facebook->getApp()->getAccessToken());
} catch (FacebookResponseException $e) {
\System::log('Facebook response exception: ' . $e->getMessage(), __METHOD__, TL_ERROR);
return null;
} catch (FacebookSDKException $e) {
\System::log('Facebook SDK exception: ' . $e->getMessage(), __METHOD__, TL_ERROR);
return null;
}
return $response;
}
示例4: testPaginationReturnsProperResponse
public function testPaginationReturnsProperResponse()
{
$config = array_merge($this->config, ['http_client_handler' => new FooClientInterface()]);
$fb = new Facebook($config);
$request = new FacebookRequest($fb->getApp(), 'foo_token', 'GET');
$graphEdge = new GraphEdge($request, [], ['paging' => ['cursors' => ['after' => 'bar_after_cursor', 'before' => 'bar_before_cursor']]], '/1337/photos', '\\Facebook\\GraphNodes\\GraphUser');
$nextPage = $fb->next($graphEdge);
$this->assertInstanceOf('Facebook\\GraphNodes\\GraphEdge', $nextPage);
$this->assertInstanceOf('Facebook\\GraphNodes\\GraphUser', $nextPage[0]);
$this->assertEquals('Foo', $nextPage[0]['name']);
$lastResponse = $fb->getLastResponse();
$this->assertInstanceOf('Facebook\\FacebookResponse', $lastResponse);
$this->assertEquals(1337, $lastResponse->getHttpStatusCode());
}
示例5: init
/**
* Init Facebook super-class object with applications settings
*/
public function init()
{
parent::init();
$this->fb = new \Facebook\Facebook(array('app_id' => $this->app_id, 'app_secret' => $this->app_secret));
$this->fb->setDefaultAccessToken($this->fb->getApp()->getAccessToken());
}
示例6: Facebook
<?php
use Facebook\Facebook;
use API\src\Config\Config;
use API\src\Server\Session;
require_once __DIR__ . '/../Autoload.php';
$fb = new Facebook(['app_id' => Config::getConfig('FacebookAppId'), 'app_secret' => Config::getConfig('FacebookSecret'), 'default_graph_version' => Config::getConfig('FacebookAPIVersion')]);
$app = $fb->getApp();
$accessToken = $app->getAccessToken();
$accessTokenValue = $accessToken->getValue();
$oauth2 = $fb->getOAuth2Client();
$tokenMeta = $oauth2->debugToken($accessToken);
$tokenMeta->validateAppId(Config::getConfig('FacebookAppId'));
$tokenMeta->validateExpiration();