具有原始参数的REST_API PHP Post

时间:2018-01-08 08:14:19

标签: php rest api post parameters

为什么我提交时会得到null结果。如何发布原始参数?

这是我的请求方法:

$urlsp = "https://xxx/xxx/forgotpassword/xxx";
$header = array("X-Application-Token : 123er", "Content-Type : application/json");
$param = array("account: 080000xxx",
            "secretQuestion:",
            "secretAnswer:",
            "newPassword: .md5($pass).",
            "issuer: 567800");
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $urlsp);
curl_setopt ($ch , CURLOPT_HTTPHEADER , $header);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $param);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$json_data = curl_exec ($ch);

curl_close ($ch);

$data = json_decode($json_data);

1 个答案:

答案 0 :(得分:1)

将您的参数更改为:

prls(req?: any): Observable<ResponseWrapper> {
    const options = createRequestOption(req);
    options.params.set('findAll', req.findAll);
    options.params.set('prlPendiente', req.prlPendiente);
    options.params.set('inicioCaduca', req.inicioCaduca);
    options.params.set('finCaduca', req.finCaduca);
    return this.http.get(this.resourceUrl+'/open/excel', options)
        .map((res: Response) =>
        res); 
}