当前位置: 首页>>代码示例>>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;未经允许,请勿转载。