CURL執行檔 POST JSON 資料到 PHP
CURL執行檔 POST JSON 資料到 PHP
GITHUB: https://github.com/jash-git/windows_curl_post2php
CURL.bat
@echo %time% curl.exe -H “Content-Type:application/json” -X POST –data ‘{“active”:1,”connection”:{“enabled”:1,”mode”:0,”port”:5001,”address”:4236355776},”apb_and_ab_door”:{“apb_enabled”:0,”apb_group”:0}}’ “http://127.0.0.1:8080/php_sleep.php” @echo %time% pause |
PHP code
<?php header(‘content-type:text/html;charset=utf-8’); set_time_limit(0);//確保不會超時 date_default_timezone_set(“Asia/Taipei”);//設定時區 //echo “start….”.date (“Y- m – d / H : i : s”) .”<br>”; //echo “\n”; $data = file_get_contents(“php://input”); sleep(3);//函數延遲代碼執行若干秒。 echo $data.”___”.date (“Y- m – d / H : i : s”); //echo “end….”.date (“Y- m – d / H : i : s”).”<br>”; ?> |
3 thoughts on “CURL執行檔 POST JSON 資料到 PHP”
PHP 抓取 header
資料來源: https://www.php.net/manual/zh/function.getallheaders.php
$value) {
echo “$name: $value\n”;
}
?>
使用CURL發送POST請求
<?php
/**
** @desc 封装 curl 的调用接口,post的请求方式
**/
function doCurlPostRequest($url,$requestString,$timeout = 5){
if($url == '' || $requestString == '' || $timeout
使用CURL發送GET請求
<?php
**
*@desc 封闭curl的调用接口,get的请求方式。
*/
function doCurlGetRequest($url,$data,$timeout = 5){
if($curl == "" || $timeout