码迷,mamicode.com
首页 > Web开发 > 详细

CURL的使用<发送与接收数据>

时间:2015-07-30 10:44:58      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:

$headers = array(
    "TYPE:xxxxooooo",
    "TOKEN:00000000"
);

$data = array(
    ‘data‘ => array(‘name‘ => ‘test‘,‘AGE‘=>22),
    ‘registration_ids‘ => array(‘APA91bEyno5XgFPvIGxMezCsnaOXwmxbHXzxAJ6X_v2w0VPEFrUb24Mw9LdeTqpA6kHkaxrwHD8N_QsBpRduKll3K9qEe2EYIw1y_rqW9UNsU_X4NsnanTVjscPBBkWVkIOfDqff6QlQJOmvA1x2kAkloq0bgMHmDe_HoWKjh1IhoDHgJzw5L2c‘)
);

$url = "http://www.adtuu-server.com/curl-get.php";
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST,count($data)) ;
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
// curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

$response = curl_exec($ch);
curl_close($ch);
var_dump($response);


$input = file_get_contents(‘php://input‘);
$input = json_decode($input, true);
var_dump($input);

var_dump($_SERVER);
var_dump($_SERVER[‘HTTP_TYPE‘]);
var_dump($_SERVER[‘HTTP_TOKEN‘]);

  

CURL的使用<发送与接收数据>

标签:

原文地址:http://www.cnblogs.com/adtuu/p/4688278.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!