I. Using curl can mimic HTTP requests and send data to the target server or destination IP for operation.
(1). Use PHP to manipulate curl to send a GET request to an interface:
The following is a relatively simple request to write request data, the parameters passed simple violence: (for reference only)
1 $ch = curl_init ("/HTTP/ 10.212.0.63/api/changeinfo?action= ". $action . " &asset= ". $asset 2 curl_setopt ( $ch , Curlopt_ Returntransfer, 1 3 $rs = curl_exec ( $ch 4 curl_close ( $ch 5 directly in Curl_init, the parameters that need get past are sent to the receiving end. 6 Note: In this case, it is limited to use the Get method to pass past data, so it is not recommended to use get to transfer data in a way.
(2). Use PHP to manipulate curl to send a POST request to an interface:
The following is also a relatively simple packaging function, it is recommended to use this method to transfer data, security and transmission of large amounts of data:
1 functionCurl_post ($params){2 3 $ch=curl_init ();4curl_setopt ($ch, Curlopt_url, "Http://10.212.0.63/Api/ChangeInfo");5curl_setopt ($ch, Curlopt_ssl_verifypeer,false );6curl_setopt ($ch, Curlopt_ssl_verifyhost,false);7 #curl_setopt ($ch, Curlopt_header, false);8 #curl_setopt ($ch, Curlopt_httpheader, $header);9curl_setopt ($ch, Curlopt_post,true );Tencurl_setopt ($ch, Curlopt_httpget,false ); Onecurl_setopt ($ch, Curlopt_postfields,$params ); Acurl_setopt ($ch, Curlopt_returntransfer,true ); - -Curl_exec ($ch); the}
Note: An array is passed $params
Two. How to judge the accuracy of the data?
You can use Json_encode () for post or get data on the receiving side, then store it in a file to view the information in the file!
Send post or get data using curl