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


    $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']);
    

      

  • 相关阅读:
    9IDEA常见的快捷键
    8Java类与对象
    5Java运算符
    10Java面向对象中级
    3Java基础
    4Java基础变量
    6Java控制结构
    7Java数组
    11Java面向对象高级
    缓存事件过期监听机制
  • 原文地址:https://www.cnblogs.com/adtuu/p/4688278.html
Copyright © 2020-2023  润新知