1. 程式人生 > >PHP curl post header

PHP curl post header

文件流 php 文件 col gis -type 打印 http family

第三方教程推薦:https://www.cnblogs.com/CHEUNGKAMING/p/5717429.html

?? index.php

<?php 
     header("Content-type: text/html; charset=utf-8");

     // 請求參數準備
     $url = "http://www.alayadata.net:8115/api/WX_Register/Sign";
     $tojson = ‘{"openId":"text","Phone":"18222705995","IdCard":"","MemberName":""}‘;
     
$header[] = "Content-Type: application/json; charset=utf-8"; $header[] = "Data-signature:C80310638874448266292D70EFA9340C"; $header[] = "Time-stamp:1515577396000"; //初始化 $ch = curl_init(); // 設置請求地址 curl_setopt($ch, CURLOPT_URL, $url); // 設置頭文件 curl_setopt($ch, CURLOPT_HTTPHEADER, $header
); // 設置獲取的信息以文件流的形式返回,而不是直接輸出。 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // 設置POST形式傳參 curl_setopt($ch, CURLOPT_POST, 1); // 設置POST請求參數 curl_setopt($ch, CURLOPT_POSTFIELDS, $tojson); // 開始CURL請求 $data = curl_exec($ch); // 關閉URL請求 curl_close($ch); //打印獲得的數據
echo $data; ?>

PHP curl post header