Use Curl to access the authorization Basic Authentication page, which is a successful code
function Postjsondata ($json) { $ch = curl_init ("Http://localhost/issues.json"); curl_setopt ($ch, Curlopt_customrequest, "POST");//Headers curl_setopt ($ch, Curlopt_httpheader, Array ( " Authorization:basic Base64 ($username. $password) ", " Content-type:application/json ", ));//$filename =" Test.json "; Change this path to yours//$fd = fopen ($filename, ' R ');//curl_setopt ($ch, Curlopt_upload, TRUE);//curl_setopt ($ch, CU Rlopt_infile, $FD);//curl_setopt ($ch, Curlopt_infilesize, FileSize ($filename)); curl_setopt ($ch, Curlopt_postfields, $json); POST this data//Send synchronously curl_setopt ($ch, Curlopt_returntransfer, TRUE); $result = curl_exec ($ch); Curl_close ($ch); return $result;}
curl_setopt ($ch, Curlopt_customrequest, "POST"); Modified to curl_setopt ($curl, Curlopt_post, true); After submitting Httpstatus 404, do not know why, record
Curl post submission appears 404