当前位置: 首页>>代码示例>>PHP>>正文


PHP FacebookSession::newAppSession方法代码示例

本文整理汇总了PHP中Facebook\FacebookSession::newAppSession方法的典型用法代码示例。如果您正苦于以下问题:PHP FacebookSession::newAppSession方法的具体用法?PHP FacebookSession::newAppSession怎么用?PHP FacebookSession::newAppSession使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Facebook\FacebookSession的用法示例。


在下文中一共展示了FacebookSession::newAppSession方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getSession

 /**
  * @return FacebookSession
  */
 protected function getSession()
 {
     if (!$this->session) {
         $this->session = FacebookSession::newAppSession();
     }
     return $this->session;
 }
开发者ID:bzis,项目名称:zomba,代码行数:10,代码来源:FacebookApiProvider.php

示例2: end

 /**
  * Returns the URL to send the user in order to log out of Facebook.
  * @return string|bool The url to log out
  */
 public function end()
 {
     if (is_null($this->fbsession)) {
         return false;
     }
     return $this->fbsession->getFacebookLoginHelperInstance()->getLogoutUrl(FacebookSession::newAppSession(), "/");
 }
开发者ID:diego3,项目名称:myframework-skeleton,代码行数:11,代码来源:FacebookService.php

示例3: register

 public function register($kernel, $options = array())
 {
     FacebookSession::setDefaultApplication($options['AppId'], $options['AppSecret']);
     $kernel->facebookSession = function () use($options) {
         return FacebookSession::newAppSession();
     };
 }
开发者ID:azole,项目名称:Phifty,代码行数:7,代码来源:Facebook4Service.php

示例4: handle

 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     // Same time next week! :D
     $job = (new \App\Jobs\WeeklyMail())->delay(604800);
     $this->dispatch($job);
     // We'll just want to double-check our Facebook events still exist
     // before we email people about them...
     FacebookSession::setDefaultApplication(getenv('FB_ID'), getenv('FB_SECRET'));
     $session = FacebookSession::newAppSession();
     try {
         $session->validate();
     } catch (FacebookRequestException $ex) {
         // Session not valid, Graph API returned an exception with the reason.
         dd($ex);
     } catch (\Exception $ex) {
         // Graph API returned info, but it may mismatch the current app or have expired.
         dd($ex);
     }
     $all_events = Event::where('time', '>', date('Y-m-d H:i:s'))->where('time', '<', date('Y-m-d H:i:s', time() + 604800))->get();
     foreach ($all_events as $event) {
         $request = new FacebookRequest($session, 'GET', "/" . $event->facebook_id);
         try {
             $response = $request->execute();
         } catch (\Exception $ex) {
             // Facebook Exception looking up event; probably deleted, should mirror here.
             $event->delete();
         }
     }
     foreach (User::where('unsubscribed_email', 'no') as $user) {
         $this->dispatch(new SendEmail($user));
     }
 }
开发者ID:boregan,项目名称:lowdown,代码行数:37,代码来源:WeeklyMail.php

示例5: getAppSession

 public function getAppSession()
 {
     if ($this->appSession) {
         return $this->appSession;
     }
     return $this->appSession = FacebookSession::newAppSession();
 }
开发者ID:wunderfactory,项目名称:weinform,代码行数:7,代码来源:Facebook.php

示例6: __construct

 public function __construct($config, $logCallback = null)
 {
     if (is_callable($logCallback)) {
         $this->logCallback = $logCallback;
     }
     FacebookSession::setDefaultApplication($config['app_id'], $config['secret']);
     $this->appSession = FacebookSession::newAppSession($config['app_id'], $config['secret']);
     $this->appId = $config['app_id'];
 }
开发者ID:namnv609,项目名称:Codeception,代码行数:9,代码来源:Facebook.php

示例7: testAppSessionValidates

 public function testAppSessionValidates()
 {
     $session = FacebookSession::newAppSession();
     try {
         $session->validate();
     } catch (\Facebook\FacebookSDKException $ex) {
         $this->fail('Exception thrown validating app session.');
     }
 }
开发者ID:sodacrackers,项目名称:washyacht,代码行数:9,代码来源:FacebookSessionTest.php

示例8: __construct

 /**
  * @param string $appId
  * @param string $appSecret
  *
  * @throws Exception\FacebookSessionException
  */
 public function __construct($appId, $appSecret)
 {
     FacebookSession::setDefaultApplication($appId, $appSecret);
     $session = FacebookSession::newAppSession();
     if (!$session) {
         throw new FacebookSessionException(sprintf('\\C2iS\\SocialWall\\Facebook\\FacebookManager needs a valid facebook session in order to make FB API calls. Check your informations for App ID "%s"', $appId));
     }
     $this->session = $session;
 }
开发者ID:c2is,项目名称:socialwall,代码行数:15,代码来源:FacebookManager.php

示例9: _getChannelV4

 private static function _getChannelV4($channel)
 {
     FacebookSession::setDefaultApplication(self::FACEBOOK_APP_ID, self::FACEBOOK_SECRET_KEY);
     $session = FacebookSession::newAppSession(self::FACEBOOK_APP_ID, self::FACEBOOK_SECRET_KEY);
     $request = new FacebookRequest($session, 'GET', '/' . $channel . '/posts?fields=type,created_time,message,picture,object_id,link');
     $response = $request->execute();
     $graphObject = $response->getGraphObject();
     return $graphObject->getPropertyAsArray('data');
 }
开发者ID:vincenthib,项目名称:framework,代码行数:9,代码来源:Facebook.class.php

示例10: build

 public function build()
 {
     if ($this->accessToken != null) {
         $session = new FacebookSession($this->accessToken);
     } else {
         $session = FacebookSession::newAppSession();
     }
     return $session;
 }
开发者ID:nagendragpu,项目名称:facebook-bot,代码行数:9,代码来源:FacebookGraphSessionBuilder.php

示例11: example

 public function example()
 {
     $application = FacebookSession::setDefaultApplication($this->config['app_id'], $this->config['app_secret']);
     $session = FacebookSession::newAppSession();
     $request = new FacebookRequest($session, 'GET', '/780788985274738');
     $response = $request->execute();
     $graphObject = $response->getGraphObject();
     $response = $this->app->json($graphObject->asArray(), 200);
     return $response;
 }
开发者ID:andyjessop,项目名称:bolt-facebook-starter,代码行数:10,代码来源:Extension.php

示例12: 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;
 }
开发者ID:bashmach,项目名称:ggf,代码行数:18,代码来源:Guard.php

示例13: getSession

 private static function getSession()
 {
     FacebookSession::setDefaultApplication('852604174797487', '9e20b12fb740a2f5f58287f4378d23b0');
     $session = FacebookSession::newAppSession();
     try {
         $session->validate();
         return $session;
     } catch (FacebookRequestException $ex) {
         // Session not valid, Graph API returned an exception with the reason.
         echo $ex->getMessage();
     } catch (\Exception $ex) {
         // Graph API returned info, but it may mismatch the current app or have expired.
         echo $ex->getMessage();
     }
 }
开发者ID:PisaCoderDojo,项目名称:dojo-wp-site,代码行数:15,代码来源:photo.php

示例14: init

 /**
  * Let's get started
  */
 protected function init()
 {
     // security - ensure we only run these scripts under CLI
     $this->requireCLI();
     parent::init();
     $this->fb = FacebookSession::newAppSession();
     try {
         $this->fb->validate();
     } catch (FacebookRequestException $ex) {
         // Session not valid, Graph API returned an exception with the reason.
         error_log($ex->getMessage());
     } catch (\Exception $ex) {
         // Graph API returned info, but it may mismatch the current app or have expired.
         error_log($ex->getMessage());
     }
 }
开发者ID:Geekathon,项目名称:Selective-Tweets,代码行数:19,代码来源:CLIApp.php

示例15: __construct

 public function __construct()
 {
     $this->ci =& get_instance();
     $this->permissions = $this->ci->config->item('permissions', 'facebook');
     // Initialize the SDK
     FacebookSession::setDefaultApplication($this->ci->config->item('api_id', 'facebook'), $this->ci->config->item('app_secret', 'facebook'));
     $this->session = FacebookSession::newAppSession();
     // Create the login helper and replace REDIRECT_URI with your URL
     // Use the same domain you set for the apps 'App Domains'
     // e.g. $helper = new FacebookRedirectLoginHelper( 'http://mydomain.com/redirect' );
     //$this->helper = new FacebookRedirectLoginHelper( $this->ci->config->item('redirect_url', 'facebook') );
     /*
         if ( $this->ci->session->userdata('fb_token') ) {
           $this->session = new FacebookSession( $this->ci->session->userdata('fb_token') );
      
           // Validate the access_token to make sure it's still valid
           try {
             if ( ! $this->session->validate() ) {
               $this->session = null;
             }
           } catch ( Exception $e ) {
             // Catch any exceptions
             $this->session = null;
           }
         } else {
           // No session exists
           try {
             $this->session = $this->helper->getSessionFromRedirect();
           } catch( FacebookRequestException $ex ) {
             // When Facebook returns an error
           } catch( Exception $ex ) {
             // When validation fails or other local issues
           }
         }
      
         if ( $this->session ) {
           $this->ci->session->set_userdata( 'fb_token', $this->session->getToken() );
      
           $this->session = new FacebookSession( $this->session->getToken() );
         }*/
 }
开发者ID:JonnoFTW,项目名称:tpfc-website,代码行数:41,代码来源:Facebook.php


注:本文中的Facebook\FacebookSession::newAppSession方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。