Fortunately, the CTO wrote me an example, and after it was saved, I wrote it.
<?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;? >
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
PHP Curl Learning