标签:
幸好CTO 给我写好了一个范例 偷偷保存下来 以后就照着这个写<?php test_put(); function test_put() { $data = array("id" => "3", "name" => "peter", "age" => 67); $data = Authorize_check($data); //print_r($data);exit; $data_string = $data; //$token = base64_encode("admin:1234"); $ch = curl_init('http://localhost/demo/index.php/member/post'); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'X-HTTP-Method-Override: POST') ); $result = curl_exec($ch); print_r($result);exit; $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); $contenttype = curl_getinfo($ch, CURLINFO_CONTENT_TYPE); print "Status: $httpcode" . "\n"; print "Content-Type: $contenttype" . "\n"; print "\n". $result . "\n"; } function Authorize_check($data){ if (is_array($data)) { $chdata=''; ksort($data); //var_dump($data);exit; foreach($data as $key => $val) { if ($key=='contact' || $key=='condition' || $key=='from') { continue; } if($key=='usersession' && empty($data['usersession'])){ $data['usersession']=''; } if($key != 'chdata'){ $chdata.=$key.'='.$val.","; } } $chdata=trim($chdata,","); $chdata=md5($chdata."jiamizifuchuan"); $data['chdata'] = $chdata; return $data; } } //list($username, $password) = explode(':', base64_decode(substr('Basic YWRtaW46MTIzNA==', 6))); //echo $username; ?>
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/agileho/article/details/47444847