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


PHP HttpClient::setContentType方法代碼示例

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


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

示例1: testJsonPost

 function testJsonPost()
 {
     $http = new HttpClient('http://localhost/coredev_testserver/post_json.php');
     $http->setContentType('application/json');
     $http->setDebug(true);
     $res = $http->post(array('str' => 'abc 123'));
     $this->assertEquals($res, 'str=abc+123');
 }
開發者ID:martinlindhe,項目名稱:core_dev,代碼行數:8,代碼來源:HttpClientTest.php

示例2: shorten

 static function shorten($input_url)
 {
     $temp = TempStore::getInstance();
     $res = $temp->get('goo.gl/' . $input_url);
     if ($res) {
         return $res;
     }
     $api_key = '';
     $http = new HttpClient('https://www.googleapis.com/urlshortener/v1/url');
     $http->setContentType('application/json');
     $res = $http->post(Json::encode(array('longUrl' => $input_url, 'key' => $api_key)));
     $res = Json::decode($res);
     if (isset($res->error)) {
         d($res->error->errors);
         throw new \Exception('Error code ' . $res->error->code . ': ' . $res->error->message);
     }
     $temp->set('goo.gl/' . $input_url, $res->id);
     return $res->id;
 }
開發者ID:martinlindhe,項目名稱:core_dev,代碼行數:19,代碼來源:ShortUrlClientGooGl.php

示例3: send

 private static function send($url, $cookies, RequestSet $set, $cookieTable)
 {
     $bits = parse_url($url);
     $host = $bits['host'];
     $port = isset($bits['port']) ? $bits['port'] : 80;
     $path = isset($bits['path']) ? $bits['path'] : '/';
     $conn = new HttpClient($host, $port);
     $conn->setCookies($cookieTable);
     $conn->setContentType("text/xml;charset=UTF-8");
     // Output ...
     $xml = $set->toXMLString();
     if (!$conn->post($path, $xml)) {
         throw new Exception("PLLClient send exception");
     }
     // Input ...
     $in_string = $conn->getContent();
     $cookieTable = $conn->getCookies();
     $resset = ResponseSet::parseXML($in_string);
     return $resset->getResponses();
 }
開發者ID:GajendraNaidu,項目名稱:openam,代碼行數:20,代碼來源:PLLClient.php

示例4: updatesmstpl

 function  updatesmstpl($smstpltag,$smstpl)
 {
     $timestamp=$this->getUnixTimeStamp();
     $digest=md5("$this->appid".md5($this->appkey)."$timestamp");
     $data=Array("smstpl"=>$smstpl,"appid"=>$this->appid,"digest"=>$digest,"timestamp"=>timestamp,"smstpltag"=>$smstpltag);
     $sendata=Array("ac"=>"updatesmstpl","data"=>$data);
     $sendata=json_encode($sendata);
     $http=new HttpClient();
     $http->setContentType("application/json");
     $ret=$http->post($this->apiurl,$senddata);
     if(!$ret)
     {
         $this->errormsg=$ret;
         return FALSE;
     }
     $retobj=json_decode($ret);
     $errorcode=$retobj->{'errorcode'};
     if($errorcode=="0")
     {
         return $retobj->{'smstpltag'};
     }
     else {
         $this->errormsg=$ret;
         return FALSE;
     }
 }
開發者ID:u34-cn,項目名稱:ikyun.net,代碼行數:26,代碼來源:smssender.php


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