import com.baidubce.http.ApiExplorerClient; import com.baidubce.http.AppSigner; import com.baidubce.http.HttpMethodName; import com.baidubce.model.ApiExplorerRequest; import com.baidubce.model.ApiExplorerResponse; // 运营商2要素V2 Java示例代码 public class RequestDemo { public static void main(String[] args) { String path = "https://sx-mobile2v2.api.bdymkt.com/mobile2/checkv2"; ApiExplorerRequest request = new ApiExplorerRequest(HttpMethodName.POST, path); request.setCredentials("您的 access key", "您的 secret key"); request.addHeaderParameter("Content-Type", "application/json;charset=UTF-8"); request.addQueryParameter("name", ""); request.addQueryParameter("mobile", ""); ApiExplorerClient client = new ApiExplorerClient(new AppSigner()); try { ApiExplorerResponse response = client.sendRequest(request); // 返回结果格式为Json字符串 System.out.println(response.getResult()); } catch (Exception e) { e.printStackTrace(); } } }
点击复制代码
{
"code": "0",
"msg": "成功",
"isFee": 1,
"seqNo": "naqeqd6ub6vvdhuixvox3e63qmak8ef7",
"data": {
"result": 1, //核验结果(1:一致,2:不一致,3:无记录)
"mobileChannel": "cmcc" //运营商,(cmcc:移动、cucc:联通、ctcc:电信)
}
}
{
"code": "1",
"msg": "请输入合法的名字",
"isFee": 0,
"seqNo": null,
"data": null
}