簡體   English   中英

需要幫助2將curl轉換為php

[英]Need Help 2 Convert curl to php

需要將Linux curl命令轉換為PHP代碼

curl -H "Host: domain.com" -H "User-Agent: Apache-HttpClient/android/S5830i" -H "Expect: 100-continue" -H "Cookie: JSESSIONID=0000czjOPByVBxvGmsdvsdsdAADSdjka56f" -H 
     "Cookie2: $Version=1" --data "plat=andro&
      secretKey=628448d5213123b89196f108de&platformver=6.0.GA_v20150301812_r23&konyreportingparams=
      {"plat":"android","aid":"ISmart","aver":"1.0.0","aname":"ecure","did":"3544621","os":"2.3.6","stype":"b2c","dm":"GT-S5530i",
      "ua":"GT-S5830i","chnl":"mobile","fid":"frmLandingPage","atype":"native",
      "kuid":"","rsid":"1450648518372-872f-70dc-c512","metrics":
      []}&serviceID=FetchOnline&cacheid=&channel=rc&appver=1.0.0&
     appID=ISmartOTP&httpconfigs= { timeout : 50.0,  } "
     --compressed https://211.211.19.39/middleware/MWServlet

您可以通過以下方式嘗試:

$fields = 2; // no of fields that can be change as per your params
$fields_as_string = "key=value&key2=value"   // insert your param here 

$url = "yoururl.com"; // your url
//open the curl connection
$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
// set the number of post fields
curl_setopt($ch,CURLOPT_POST, $fields);
// set the fields
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_as_string);

//execute post
$result = curl_exec($ch);

//close connection
curl_close($ch);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM