當前位置: 首頁>>代碼示例>>PHP>>正文


PHP HTTPRequest::addHeaders方法代碼示例

本文整理匯總了PHP中HTTPRequest::addHeaders方法的典型用法代碼示例。如果您正苦於以下問題:PHP HTTPRequest::addHeaders方法的具體用法?PHP HTTPRequest::addHeaders怎麽用?PHP HTTPRequest::addHeaders使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在HTTPRequest的用法示例。


在下文中一共展示了HTTPRequest::addHeaders方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: deleteFile

 /**
  * 刪除文件,要auth認證
  * @example shell curl -i -H 'Authorization: QBox asdf' 'http://rs.qbox.me/delete/asdf'
  * @return boolean
  */
 public function deleteFile($remoteFileName)
 {
     $remoteFileName = str_replace('/', '', $remoteFileName);
     $uri = 'http://' . str_replace('//', '/', $this->conf['host']['rs'] . '/delete/') . $this->encode($this->bucket . ':' . $remoteFileName);
     $policy = array('scope' => $this->bucket, 'deadline' => time() + 3600);
     $tmp = parse_url($uri);
     $auth = $this->sign($tmp['path'] . "\n");
     $http = new \HTTPRequest($uri, HTTP_METH_POST);
     $http->addHeaders(array('Authorization' => 'QBox ' . $auth));
     $r = $http->send();
     $body = json_decode($http->getResponseBody(), true);
     $code = $http->getResponseCode();
     //612是文件不存在
     if ($code == 200 || $code == 612) {
         return true;
     }
     throw new Exception($body['error'], $code);
 }
開發者ID:sinkcup,項目名稱:qiniu-sdk-php,代碼行數:23,代碼來源:RS.php

示例2: decode

 public function decode($point = array('lat' => null, 'lng' => null))
 {
     $uri = 'http://maps.googleapis.com/maps/api/geocode/json?sensor=false&latlng=' . $point['lat'] . ',' . $point['lng'];
     $http = new \HTTPRequest($uri, HTTP_METH_GET);
     if (isset($this->conf['lang'])) {
         $http->addHeaders(array('Accept-Language' => $this->conf['lang']));
     }
     $http->send();
     $code = $http->getResponseCode();
     if ($code != 200) {
         throw new Exception('http error', $code);
     }
     $r = json_decode($http->getResponseBody(), true);
     if (!isset($r['results'][0]['formatted_address'])) {
         throw new Exception($r['status'], -1);
     }
     return array('address' => $r['results'][0]['formatted_address']);
 }
開發者ID:sinkcup,項目名稱:location-based-service-php,代碼行數:18,代碼來源:GoogleMaps.php


注:本文中的HTTPRequest::addHeaders方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。