Multipart/form-data Way
Post's Curl library, simulate post submission, the default way Multipart/form-data, this is a post submission of several basic implementation methods.
$POSTURL = ';
$postData = Array (
' user_name ' => $userName,
' Identity_no ' => $idCardNo
);
$curl = Curl_init ();
curl_setopt ($curl, Curlopt_url, $POSTURL);
curl_setopt ($curl, Curlopt_useragent, ' opera/9.80 (Windows NT 6.2; Win64; x64) presto/2.12.388 version/12.15 ');
curl_setopt ($curl, Curlopt_ssl_verifypeer, false); Stop Verifying certificate
curl_setopt ($curl, Curlopt_returntransfer, true);
curl_setopt ($curl, Curlopt_post, true);
curl_setopt ($curl, Curlopt_postfields, $postData);
curl_setopt ($curl, curlopt_followlocation, true);
$r = curl_exec ($curl);
Curl_close ($curl);
Print_r ($R);
If you want to use it, you can try it directly.
X-www-form-urlencoded Way
It's quite handy to post a PHP curl library. However, different submissions, ContentType different causes your API can receive data is also a variable, here to a simple example.
$POSTURL = ';
$postData = Array (
' user_name ' => $userName,
' Identity_no ' => $idCardNo
);
$postData = Http_build_query ($postData);
$curl = Curl_init ();
curl_setopt ($curl, Curlopt_url, $POSTURL);
curl_setopt ($curl, Curlopt_useragent, ' opera/9.80 (Windows NT 6.2; Win64; x64) presto/2.12.388 version/12.15 ');
curl_setopt ($curl, Curlopt_ssl_verifypeer, false); Stop Verifying certificate
curl_setopt ($curl, Curlopt_returntransfer, true);
curl_setopt ($curl, Curlopt_post, true);
curl_setopt ($curl, Curlopt_httpheader, Array (' content-type:application/x-www-form-urlencoded '));
curl_setopt ($curl, Curlopt_postfields, $postData);
curl_setopt ($curl, curlopt_followlocation, true);
$r = curl_exec ($curl);
Curl_close ($curl);
Print_r ($R);
The key piece of code is
Curl_setopt ($curl, Curlopt_httpheader, Array (' content-type:application/x-www-form-urlencoded '));