程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> 關於PHP編程 >> php之curl學習

php之curl學習

編輯:關於PHP編程

php之curl學習


幸好CTO 給我寫好了一個范例 偷偷保存下來 以後就照著這個寫 吐舌頭
 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 . 
;
	   print Content-Type: $contenttype . 
;
	   print 
. $result . 
;
	}

	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;

?>

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved