标签:password pass 参数 tput http verify lob ret false
curl想要传递二维数组.或者更维的数组时
<?php
header("Content-type: text/html;charset=utf-8");
$url = "";
// 参数数组
$data = array (
‘name‘ => ‘tanteng‘,
‘password‘ => ‘password‘,
‘method‘ => array(1,2,3)
);
$ch = curl_init ();
// print_r($ch);
$data = json_encode($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
// 我们在POST数据哦!
curl_setopt($ch, CURLOPT_POST, 1);
// 把post的变量加上
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
/* curl_setopt($ch, CURLOPT_HTTPHEADER, array( 如果添加了头部说明,dump($GLOBALS[‘HTTP_RAW_POST_DATA‘]);可以接受到
‘Content-Type: application/json‘, 如果没有添加头部说明 dump( file_get_contents("php://input")); 可以接受到
‘Content-Length: ‘ . strlen($data)
));*/
$output = curl_exec($ch);
var_dump($output);
curl_close($ch);
接受时
dump($_POST);
dump($GLOBALS[‘HTTP_RAW_POST_DATA‘]);
dump( file_get_contents("php://input"));
标签:password pass 参数 tput http verify lob ret false
原文地址:http://www.cnblogs.com/666-zhouliang/p/7602842.html