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


PHP Gdn_Controller::DeliveryMethod方法代码示例

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


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

示例1: Base_ConnectData_Handler

 /**
  *
  * @param Gdn_Controller $Sender
  * @param array $Args
  */
 public function Base_ConnectData_Handler($Sender, $Args)
 {
     if (GetValue(0, $Args) != 'sinaconnect') {
         return;
     }
     $RequestToken = GetValue('oauth_token', $_GET);
     // Get the access token.
     if ($RequestToken || !($AccessToken = $this->AccessToken())) {
         // Get the request secret.
         $RequestToken = $this->GetOAuthToken($RequestToken);
         $Consumer = new OAuthConsumer(C('Plugins.SinaConnect.ConsumerKey'), C('Plugins.SinaConnect.Secret'));
         $Url = 'http://api.t.sina.com.cn/oauth/access_token';
         $Params = array('oauth_verifier' => GetValue('oauth_verifier', $_GET));
         $Request = OAuthRequest::from_consumer_and_token($Consumer, $RequestToken, 'POST', $Url, $Params);
         $SignatureMethod = new OAuthSignatureMethod_HMAC_SHA1();
         $Request->sign_request($SignatureMethod, $Consumer, $RequestToken);
         $Post = $Request->to_postdata();
         $Curl = $this->_Curl($Request);
         $Response = curl_exec($Curl);
         if ($Response === FALSE) {
             $Response = curl_error($Curl);
         }
         $HttpCode = curl_getinfo($Curl, CURLINFO_HTTP_CODE);
         curl_close($Curl);
         if ($HttpCode == '200') {
             $Data = OAuthUtil::parse_parameters($Response);
             $AccessToken = $this->AccessToken(GetValue('oauth_token', $Data), GetValue('oauth_token_secret', $Data));
             // Save the access token to the database.
             $this->SetOAuthToken($AccessToken);
             // Delete the request token.
             $this->DeleteOAuthToken($RequestToken);
         } else {
             // There was some sort of error.
         }
         $NewToken = TRUE;
     }
     // Get the profile.
     try {
         $Profile = $this->GetProfile($AccessToken);
     } catch (Exception $Ex) {
         if (!isset($NewToken)) {
             // There was an error getting the profile, which probably means the saved access token is no longer valid. Try and reauthorize.
             if ($Sender->DeliveryType() == DELIVERY_TYPE_ALL) {
                 Redirect($this->_AuthorizeHref());
             } else {
                 $Sender->SetHeader('Content-type', 'application/json');
                 $Sender->DeliveryMethod(DELIVERY_METHOD_JSON);
                 $Sender->RedirectUrl = $this->_AuthorizeHref();
             }
         } else {
             $Sender->Form->AddError($Ex);
         }
     }
     //print_r($Profile);
     $Form = $Sender->Form;
     //new Gdn_Form();
     $ID = GetValue('id', $Profile);
     $Form->SetFormValue('UniqueID', $ID);
     $Form->SetFormValue('Provider', self::$ProviderKey);
     $Form->SetFormValue('ProviderName', 'Sina');
     $Form->SetFormValue('Name', GetValue('screen_name', $Profile));
     $Form->SetFormValue('FullName', GetValue('name', $Profile));
     $Form->SetFormValue('Email', GetValue('id', $Profile) . '@weibo.com');
     $Form->SetFormValue('Photo', GetValue('profile_image_url', $Profile));
     $Sender->SetData('Verified', TRUE);
 }
开发者ID:edward-tsai,项目名称:vanilla4china,代码行数:71,代码来源:class.sinaconnect.plugin.php

示例2: UtilityController_SiteMapIndex_Create

 /**
  * @param Gdn_Controller $Sender
  * @param type $Args 
  */
 public function UtilityController_SiteMapIndex_Create($Sender)
 {
     // Clear the session to mimic a crawler.
     Gdn::Session()->Start(0, FALSE, FALSE);
     $Sender->DeliveryMethod(DELIVERY_METHOD_XHTML);
     $Sender->DeliveryType(DELIVERY_TYPE_VIEW);
     $Sender->SetHeader('Content-Type', 'text/xml');
     $SiteMaps = array();
     if (class_exists('CategoryModel')) {
         $Categories = CategoryModel::Categories();
         foreach ($Categories as $Category) {
             if (!$Category['PermsDiscussionsView'] || $Category['CategoryID'] < 0 || $Category['CountDiscussions'] == 0) {
                 continue;
             }
             $SiteMap = array('Loc' => Url('/sitemap-category-' . rawurlencode($Category['UrlCode'] ? $Category['UrlCode'] : $Category['CategoryID']) . '.xml', TRUE), 'LastMod' => $Category['DateLastComment'], 'ChangeFreq' => '', 'Priority' => '');
             $SiteMaps[] = $SiteMap;
         }
     }
     $Sender->SetData('SiteMaps', $SiteMaps);
     $Sender->Render('SiteMapIndex', '', 'plugins/Sitemaps');
 }
开发者ID:SatiricMan,项目名称:addons,代码行数:25,代码来源:class.sitemaps.plugin.php

示例3: Base_ConnectData_Handler

 /**
  *
  * @param Gdn_Controller $Sender
  * @param array $Args
  */
 public function Base_ConnectData_Handler($Sender, $Args)
 {
     if (GetValue(0, $Args) != 'twitter') {
         return;
     }
     $Form = $Sender->Form;
     //new Gdn_Form();
     $RequestToken = GetValue('oauth_token', $_GET);
     $AccessToken = $Form->GetFormValue('AccessToken');
     if ($AccessToken) {
         $AccessToken = $this->GetOAuthToken($AccessToken);
         $this->AccessToken($AccessToken);
     }
     // Get the access token.
     if ($RequestToken && !$AccessToken) {
         // Get the request secret.
         $RequestToken = $this->GetOAuthToken($RequestToken);
         $Consumer = new OAuthConsumer(C('Plugins.Twitter.ConsumerKey'), C('Plugins.Twitter.Secret'));
         $Url = 'https://api.twitter.com/oauth/access_token';
         $Params = array('oauth_verifier' => GetValue('oauth_verifier', $_GET));
         $Request = OAuthRequest::from_consumer_and_token($Consumer, $RequestToken, 'POST', $Url, $Params);
         $SignatureMethod = new OAuthSignatureMethod_HMAC_SHA1();
         $Request->sign_request($SignatureMethod, $Consumer, $RequestToken);
         $Post = $Request->to_postdata();
         $Curl = $this->_Curl($Request);
         $Response = curl_exec($Curl);
         if ($Response === FALSE) {
             $Response = curl_error($Curl);
         }
         $HttpCode = curl_getinfo($Curl, CURLINFO_HTTP_CODE);
         curl_close($Curl);
         if ($HttpCode == '200') {
             $Data = OAuthUtil::parse_parameters($Response);
             $AccessToken = new OAuthToken(GetValue('oauth_token', $Data), GetValue('oauth_token_secret', $Data));
             // Save the access token to the database.
             $this->SetOAuthToken($AccessToken->key, $AccessToken->secret, 'access');
             $this->AccessToken($AccessToken->key, $AccessToken->secret);
             // Delete the request token.
             $this->DeleteOAuthToken($RequestToken);
         } else {
             // There was some sort of error.
             throw new Exception('There was an error authenticating with twitter.', 400);
         }
         $NewToken = TRUE;
     }
     // Get the profile.
     try {
         $Profile = $this->GetProfile($AccessToken);
     } catch (Exception $Ex) {
         if (!isset($NewToken)) {
             // There was an error getting the profile, which probably means the saved access token is no longer valid. Try and reauthorize.
             if ($Sender->DeliveryType() == DELIVERY_TYPE_ALL) {
                 Redirect($this->_AuthorizeHref());
             } else {
                 $Sender->SetHeader('Content-type', 'application/json');
                 $Sender->DeliveryMethod(DELIVERY_METHOD_JSON);
                 $Sender->RedirectUrl = $this->_AuthorizeHref();
             }
         } else {
             throw $Ex;
         }
     }
     $ID = GetValue('id', $Profile);
     $Form->SetFormValue('UniqueID', $ID);
     $Form->SetFormValue('Provider', self::ProviderKey);
     $Form->SetFormValue('ProviderName', 'Twitter');
     $Form->SetValue('ConnectName', GetValue('screen_name', $Profile));
     $Form->SetFormValue('Name', GetValue('screen_name', $Profile));
     $Form->SetFormValue('FullName', GetValue('name', $Profile));
     $Form->SetFormValue('Photo', GetValue('profile_image_url', $Profile));
     $Form->AddHidden('AccessToken', $AccessToken->key);
     // Save some original data in the attributes of the connection for later API calls.
     $Attributes = array(self::ProviderKey => array('AccessToken' => array($AccessToken->key, $AccessToken->secret), 'Profile' => $Profile));
     $Form->SetFormValue('Attributes', $Attributes);
     $Sender->SetData('Verified', TRUE);
 }
开发者ID:robhazkes,项目名称:Garden,代码行数:81,代码来源:class.twitter.plugin.php

示例4: SettingsController_AnalyticsTick_Create

 /**
  * 
  * @param Gdn_Controller $Sender
  */
 public function SettingsController_AnalyticsTick_Create($Sender)
 {
     $Sender->DeliveryMethod(DELIVERY_METHOD_JSON);
     $Sender->DeliveryType(DELIVERY_TYPE_DATA);
     Gdn::Statistics()->Tick();
     $this->FireEvent("AnalyticsTick");
     $Sender->DeliveryType(DELIVERY_TYPE_VIEW);
     $Sender->Render('tick', 'statistics', 'dashboard');
 }
开发者ID:elpum,项目名称:TgaForumBundle,代码行数:13,代码来源:class.statistics.php

示例5: Base_ConnectData_Handler

 /**
  *
  * @param Gdn_Controller $Sender
  * @param array $Args
  */
 public function Base_ConnectData_Handler($Sender, $Args)
 {
     if (GetValue(0, $Args) != 'facebook') {
         return;
     }
     if (isset($_GET['error'])) {
         throw new Gdn_UserException(GetValue('error_description', $_GET, T('There was an error connecting to Facebook')));
     }
     $AppID = C('Plugins.Facebook.ApplicationID');
     $Secret = C('Plugins.Facebook.Secret');
     $Code = GetValue('code', $_GET);
     $Query = '';
     if ($Sender->Request->Get('display')) {
         $Query = 'display=' . urlencode($Sender->Request->Get('display'));
     }
     $RedirectUri = ConcatSep('&', $this->RedirectUri(), $Query);
     $RedirectUri = urlencode($RedirectUri);
     // Get the access token.
     if ($Code || !($AccessToken = $this->AccessToken())) {
         // Exchange the token for an access token.
         $Code = urlencode($Code);
         $Url = "https://graph.facebook.com/oauth/access_token?client_id={$AppID}&client_secret={$Secret}&code={$Code}&redirect_uri={$RedirectUri}";
         // Get the redirect URI.
         $C = curl_init();
         curl_setopt($C, CURLOPT_RETURNTRANSFER, TRUE);
         curl_setopt($C, CURLOPT_SSL_VERIFYPEER, FALSE);
         curl_setopt($C, CURLOPT_URL, $Url);
         $Contents = curl_exec($C);
         //         $Contents = ProxyRequest($Url);
         $Info = curl_getinfo($C);
         if (strpos(GetValue('content_type', $Info, ''), '/javascript') !== FALSE) {
             $Tokens = json_decode($Contents, TRUE);
         } else {
             parse_str($Contents, $Tokens);
         }
         if (GetValue('error', $Tokens)) {
             throw new Gdn_UserException('Facebook returned the following error: ' . GetValueR('error.message', $Tokens, 'Unknown error.'), 400);
         }
         $AccessToken = GetValue('access_token', $Tokens);
         $Expires = GetValue('expires', $Tokens, NULL);
         setcookie('fb_access_token', $AccessToken, time() + $Expires, C('Garden.Cookie.Path', '/'), C('Garden.Cookie.Domain', ''), NULL, TRUE);
         $NewToken = TRUE;
     }
     // Get the profile.
     try {
         $Profile = $this->GetProfile($AccessToken);
     } catch (Exception $Ex) {
         if (!isset($NewToken)) {
             // There was an error getting the profile, which probably means the saved access token is no longer valid. Try and reauthorize.
             if ($Sender->DeliveryType() == DELIVERY_TYPE_ALL) {
                 Redirect($this->AuthorizeUri());
             } else {
                 $Sender->SetHeader('Content-type', 'application/json');
                 $Sender->DeliveryMethod(DELIVERY_METHOD_JSON);
                 $Sender->RedirectUrl = $this->AuthorizeUri();
             }
         } else {
             $Sender->Form->AddError('There was an error with the Facebook connection.');
         }
     }
     $Form = $Sender->Form;
     //new Gdn_Form();
     $ID = GetValue('id', $Profile);
     $Form->SetFormValue('UniqueID', $ID);
     $Form->SetFormValue('Provider', 'facebook');
     $Form->SetFormValue('ProviderName', 'Facebook');
     $Form->SetFormValue('FullName', GetValue('name', $Profile));
     $Form->SetFormValue('Email', GetValue('email', $Profile));
     $Form->SetFormValue('Photo', "http://graph.facebook.com/{$ID}/picture");
     if (C('Plugins.Facebook.UseFacebookNames')) {
         $Form->SetFormValue('Name', GetValue('name', $Profile));
         SaveToConfig(array('Garden.User.ValidationRegex' => UserModel::USERNAME_REGEX_MIN, 'Garden.User.ValidationLength' => '{3,50}', 'Garden.Registration.NameUnique' => FALSE), '', FALSE);
     }
     // Save some original data in the attributes of the connection for later API calls.
     $Attributes = array('Facebook.Profile' => $Profile);
     $Form->SetFormValue('Attributes', $Attributes);
     $Sender->SetData('Verified', TRUE);
 }
开发者ID:rnovino,项目名称:Garden,代码行数:83,代码来源:class.facebook.plugin.php

示例6: Base_ConnectData_Handler

 /**
  *
  * @param Gdn_Controller $Sender
  * @param array $Args
  */
 public function Base_ConnectData_Handler($Sender, $Args)
 {
     if (GetValue(0, $Args) != 'facebook') {
         return;
     }
     if (isset($_GET['error'])) {
         throw new Gdn_UserException(GetValue('error_description', $_GET, T('There was an error connecting to Facebook')));
     }
     $AppID = C('Plugins.Facebook.ApplicationID');
     $Secret = C('Plugins.Facebook.Secret');
     $Code = GetValue('code', $_GET);
     $Query = '';
     if ($Sender->Request->Get('display')) {
         $Query = 'display=' . urlencode($Sender->Request->Get('display'));
     }
     $RedirectUri = ConcatSep('&', $this->RedirectUri(), $Query);
     //      $RedirectUri = urlencode($RedirectUri);
     // Get the access token.
     if ($Code) {
         // Exchange the token for an access token.
         $Code = urlencode($Code);
         $AccessToken = $this->GetAccessToken($Code, $RedirectUri);
         $NewToken = TRUE;
     }
     // Get the profile.
     try {
         $Profile = $this->GetProfile($AccessToken);
     } catch (Exception $Ex) {
         if (!isset($NewToken)) {
             // There was an error getting the profile, which probably means the saved access token is no longer valid. Try and reauthorize.
             if ($Sender->DeliveryType() == DELIVERY_TYPE_ALL) {
                 Redirect($this->AuthorizeUri());
             } else {
                 $Sender->SetHeader('Content-type', 'application/json');
                 $Sender->DeliveryMethod(DELIVERY_METHOD_JSON);
                 $Sender->RedirectUrl = $this->AuthorizeUri();
             }
         } else {
             $Sender->Form->AddError('There was an error with the Facebook connection.');
         }
     }
     $Form = $Sender->Form;
     //new Gdn_Form();
     $ID = GetValue('id', $Profile);
     $Form->SetFormValue('UniqueID', $ID);
     $Form->SetFormValue('Provider', self::ProviderKey);
     $Form->SetFormValue('ProviderName', 'Facebook');
     $Form->SetFormValue('FullName', GetValue('name', $Profile));
     $Form->SetFormValue('Email', GetValue('email', $Profile));
     $Form->SetFormValue('Photo', "http://graph.facebook.com/{$ID}/picture");
     if (C('Plugins.Facebook.UseFacebookNames')) {
         $Form->SetFormValue('Name', GetValue('name', $Profile));
         SaveToConfig(array('Garden.User.ValidationRegex' => UserModel::USERNAME_REGEX_MIN, 'Garden.User.ValidationLength' => '{3,50}', 'Garden.Registration.NameUnique' => FALSE), '', FALSE);
     }
     // Save some original data in the attributes of the connection for later API calls.
     $Attributes = array();
     $Attributes[self::ProviderKey] = array('AccessToken' => $AccessToken, 'Profile' => $Profile);
     $Form->SetFormValue('Attributes', $Attributes);
     $Sender->SetData('Verified', TRUE);
 }
开发者ID:robhazkes,项目名称:Garden,代码行数:65,代码来源:class.facebook.plugin.php

示例7: Base_ConnectData_Handler

 /**
  *
  * @param Gdn_Controller $Sender
  * @param array $Args
  */
 public function Base_ConnectData_Handler($Sender, $Args)
 {
     if (GetValue(0, $Args) != 'accounts9') {
         return;
     }
     if (isset($_GET['error'])) {
         throw new Gdn_UserException(GetValue('error_description', $_GET, T('There was an error connecting to Accounts9')));
     }
     $AppID = C('Plugins.Accounts9.ApplicationID');
     $Secret = C('Plugins.Accounts9.Secret');
     if (!$Code) {
         if (!isset($_GET['code'])) {
             throw new Gdn_UserException('could not retrieve code out of callback request and no code given');
         }
         $Code = $_GET['code'];
     }
     $Code = GetValue('code', $_GET);
     /*     $Query = '';
           if ($Sender->Request->Get('display'))
              $Query = 'display='.urlencode($Sender->Request->Get('display'));
       */
     $RedirectUri = ConcatSep('&', $this->RedirectUri(), $Query);
     $RedirectUri = urlencode($RedirectUri);
     // Get the access token.
     if ($Code || !($AccessToken = $this->AccessToken())) {
         // Exchange the token for an access token.
         $Code = urlencode($Code);
         $Url = "https://accounts.net9.org/api/access_token?client_id={$AppID}&client_secret={$Secret}&code={$Code}&redirect_uri={$RedirectUri}";
         // Get the redirect URI.
         $C = curl_init();
         curl_setopt($C, CURLOPT_RETURNTRANSFER, TRUE);
         curl_setopt($C, CURLOPT_SSL_VERIFYPEER, FALSE);
         curl_setopt($C, CURLOPT_URL, $Url);
         $Contents = curl_exec($C);
         //         $Contents = ProxyRequest($Url);
         $Info = curl_getinfo($C);
         //        if (strpos(GetValue('content_type', $Info, ''), '/javascript') !== FALSE) {
         $Tokens = json_decode($Contents, TRUE);
         /* } else {
                     parse_str($Contents, $Tokens);
         	 }*/
         if (GetValue('error', $Tokens)) {
             throw new Gdn_UserException('Accounts9 returned the following error: ' . GetValueR('error.message', $Tokens, 'Unknown error.'), 400);
         }
         $AccessToken = GetValue('access_token', $Tokens);
         $Expires = GetValue('expires_in', $Tokens, NULL);
         setcookie('accounts9_access_token', $AccessToken, time() + $Expires, C('Garden.Cookie.Path', '/'), C('Garden.Cookie.Domain', ''));
         $NewToken = TRUE;
     }
     // Get the profile.
     try {
         $Profile = $this->GetProfile($AccessToken);
     } catch (Exception $Ex) {
         if (!isset($NewToken)) {
             // There was an error getting the profile, which probably means the saved access token is no longer valid. Try and reauthorize.
             if ($Sender->DeliveryType() == DELIVERY_TYPE_ALL) {
                 Redirect($this->AuthorizeUri());
             } else {
                 $Sender->SetHeader('Content-type', 'application/json');
                 $Sender->DeliveryMethod(DELIVERY_METHOD_JSON);
                 $Sender->RedirectUrl = $this->AuthorizeUri();
             }
         } else {
             $Sender->Form->AddError('There was an error with the Accounts9 connection.');
         }
     }
     //throw new Gdn_UserException($Profile);
     $User = GetValue("user", $Profile);
     //      throw new Gdn_UserException($User['uid']);
     //      $User = json_decode($UContents,TRUE);
     $Form = $Sender->Form;
     //new Gdn_Form();
     $ID = GetValue('uid', $User);
     $Form->SetFormValue('UniqueID', $ID);
     $Form->SetFormValue('Provider', 'accounts9');
     $Form->SetFormValue('ProviderName', 'Accounts9');
     $Form->SetFormValue('Name', GetValue('name', $User));
     $Form->SetFormValue('NickName', GetValue('nickname', $User));
     $Form->SetFormValue('FullName', GetValue('username', $User));
     $Form->SetFormValue('Email', GetValue('email', $User));
     //      $Form->SetFormValue('Photo', "http://graph.facebook.com/$ID/picture");
     $Sender->SetData('Verified', TRUE);
 }
开发者ID:net9,项目名称:forum9,代码行数:88,代码来源:class.accounts9.plugin.php


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