【发布时间】:2020-11-07 14:41:28
【问题描述】:
我有这个curl 请求,它有效:
curl -X POST "https://peyk.uk/api/v1/get-auth-token"
-F "client_id=xxxxx"
-F "client_secret=xxxx"
但是当尝试使用wp_remote_post 进行复制时,我不断收到代码 0 响应,这根本没有帮助。
我尝试了很多不同的组合,但目前我的请求如下所示:
$body = json_encode(array(
'client_id' => $this->settings['client_id'],
'client_secret' => $this->settings['client_secret']
));
$result = wp_remote_post('https://peyk.uk/api/v1/get-auth-token', array(
'method' => 'POST',
'headers' => array('Content-Type' => 'multipart/form-data'),
'body'=> array('formdata' => $body)
));
有什么想法吗?
【问题讨论】:
标签: php wordpress curl multipartform-data