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


PHP Curl::getDocument方法代码示例

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


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

示例1: fetchGravatar

 /**
  * Get actual avatar data (jpeg binary data)
  *
  * @param $since
  * @param $etag
  * @return unknown_type
  */
 public function fetchGravatar($since = null, $etag = null)
 {
     $oHTTP = new Curl();
     if (!isset($this->url)) {
         $this->setAvatarUrl();
     }
     try {
         $this->oResponse = $oHTTP->getDocument($this->url, $since, $etag)->checkResponse();
         $this->gravatar = $this->oResponse->getResponseBody();
         $this->gravatarExists = 'Y';
         d('has gravatar = Y');
     } catch (Exception $e) {
         $this->gravatarExists = 'U';
         if ($e instanceof Http404Exception) {
             d('No gravatar');
             $this->gravatarExists = 'N';
         }
     }
     return $this;
 }
开发者ID:netconstructor,项目名称:LampCMS,代码行数:27,代码来源:Gravatar.php

示例2: getGfcData

 /**
  * Get JSON data from the server for this user
  * If timeout, then what? Then we will throw our own
  * Exception and user will see a message
  * that timeout has occured
  *
  *
  * @param string $fcauth value of fcauth cookie
  */
 protected function getGfcData()
 {
     $url = 'http://www.google.com/friendconnect/api/people/@viewer/@self?fcauth=' . $this->fcauth;
     $oHTTP = new Curl();
     try {
         d('cp');
         $this->oResponse = $oHTTP->getDocument($url)->checkResponse();
         $gfcJson = $this->oResponse->getResponseBody();
         d('gfcJson ' . $gfcJson);
         $aGfcData = json_decode($gfcJson, true);
         d('$gGfcData: ' . print_r($aGfcData, 1));
         if (empty($aGfcData) || !is_array($aGfcData) || !array_key_exists('entry', $aGfcData) || empty($aGfcData['entry']['id'])) {
             throw new GFCAuthException('Invalid data returned by FriendConnect server');
         }
         $this->aGfcData = $aGfcData['entry'];
         /**
         * this->gGfcData: Array
         (
         [entry] => Array
         (
         [isViewer] => 1
         [id] => 11683420763934692837
         [thumbnailUrl] => http://www.google.com/friendconnect/scs/images/NoPictureDark.png
         [photos] => Array
         (
         [0] => Array
         (
         [value] => http://www.google.com/friendconnect/scs/images/NoPictureDark.png
         [type] => thumbnail
         )
         
         )
         
         [displayName] => David Smith
         )
         
         )
         */
     } catch (HttpTimeoutException $e) {
         d('Request to GFC server timedout');
         throw new GFCAuthException('Request to Google Friend connect server timed out. Please try again later');
     } catch (Http401Exception $e) {
         d('Unauthorized to get data from gfc, most likely user unjoined the site');
         $this->revokeFcauth();
         throw new GFCAuthException('Anauthorized with Friend Connect server');
     } catch (HttpResponseCodeException $e) {
         e('LampcmsError gfc response exception: ' . $e->getHttpCode() . ' ' . $e->getMessage());
         /**
          * The non-200 response code means there is some kind
          * of error, maybe authorization failed or something like that,
          * or maybe Friend Connect server was acting up,
          * in this case it is better to delete fcauth cookies
          * so that we dont go through these steps again.
          * User will just have to re-do the login fir GFC step
          */
         Cookie::delete(array('fcauth' . $this->gfcSiteId . '-s', 'fcauth' . $this->gfcSiteId));
         throw new GFCAuthException('Error during authentication with Friend Connect server');
     }
 }
开发者ID:narodev,项目名称:LampCMS-for-Open-org.com,代码行数:68,代码来源:ExternalAuthGfc.php

示例3: pingSearchSites

 /**
  * Ping a bunch of search engines to tell
  * them about our new sitemap file
  *
  * @return object $this
  */
 protected function pingSearchSites()
 {
     $Http = new Curl();
     $url = $this->baseUrl . '/w/sitemap/' . $this->siteMapName;
     foreach ($this->aPingUrls as $key => $val) {
         try {
             $pingUrl = sprintf($val, $url);
             d('going to ping ' . $key . ' url: ' . $pingUrl);
             $Http->getDocument($url);
             $code = $Http->getHttpResponseCode();
             d('pinged ' . $key . ' response code: ' . $code);
         } catch (\Exception $e) {
             $err = 'Unable to ping ' . $key . ' got error: ' . $e->getMessage();
             e('Error: ' . $err);
         }
     }
     return $this;
 }
开发者ID:codigoirreverente,项目名称:LampCMS,代码行数:24,代码来源:SiteMap.php


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