
php发送请求以及怎么得到json中的字段的值
展开全部
用curl$ch = curl_init();$header[] = "Content-type: text/xml";//定义content-type为xmlcurl_setopt($ch, CURLOPT_URL, $url); //定义表单提交地址curl_setopt($ch, CURLOPT_POST, 1); //定义提交类型 1:POST ;0:GETcurl_setopt($ch, CURLOPT_HEADER, 1); //定义是否显示状态头 1:显示 ; 0:不显示curl_setopt($ch, CURLOPT_HTTPHEADER, $header);//定义请求类型 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);//定义是否直接输出返回流 curl_setopt($ch, CURLOPT_POSTFIELDS, $postStr); //定义提交的数据,这里是XML文件 $res = curl_exec($ch);curl_close($ch);//关闭
或者发送一个 http Content-Type头信息,即 “Content-Type: application/json; charset=utf-8”
或者发送一个 http Content-Type头信息,即 “Content-Type: application/json; charset=utf-8”
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询