php之curl学习_PHP教程
程序员文章站
2022-04-08 10:41:00
...
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; ?>
推荐阅读
-
PHP学习记录之面向对象(Object-oriented programming,OOP)基础【类、对象、继承等】
-
PHP设计模式之观察者模式实例
-
php采集神器cURL使用方法详解
-
PHP设计模式之工厂模式(Factory)入门与应用详解
-
PHP设计模式之单例模式入门与应用详解
-
PHP设计模式之策略模式(Strategy)入门与应用案例详解
-
PHP设计模式之迭代器(Iterator)模式入门与应用详解
-
PHP学习记录之面向对象(Object-oriented programming,OOP)基础【接口、抽象类、静态方法等】
-
PHP设计模式之观察者模式入门与应用案例详解
-
PHP的Yii框架入门使用教程