用php模拟登陆使用credential做用户参数,为什么报用户名不能为空
$url = "http://xxxx:20020/x_organization_assemble_authentication/jaxrs/authentication";$cookie = "c:/cookie.txt";
$post = array("credential"=>"xadmin","password"=>"o2");
$headers[] = "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;";
$headers[] = "Connection: keep-alive";
$headers[] = "Content-Type: application/json; charset=utf-8;";
$headers[] = "user-agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)";
$curl = curl_init();//初始化curl模块
curl_setopt($curl, CURLOPT_URL, $url);//登录提交的地址
curl_setopt($curl, CURLOPT_HEADER, 0);//是否显示头信息
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 0);//是否自动显示返回的信息
curl_setopt($curl, CURLOPT_COOKIEJAR, $cookie); //设置Cookie信息保存在指定的文件中
curl_setopt($curl, CURLOPT_POST, 1);//post方式提交
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post));//要提交的信息
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($curl);//执行cURL
curl_close($curl);
===============================================================
{ "type": "error", "message": "用户名不能为空.", "date": "2020-08-11 20:21:17", "spent": 1, "size": -1, "count": 0, "position": 0, "prompt": "com.x.organization.assemble.authentication.jaxrs.authentication.ExceptionCredentialEmpty" } 您好:php不太懂
不过您遵循该接口的数据规范,应该都是没问题的。
1.json
2.post
3.如果是中文,建议查一下编码方式
页:
[1]