WordPress JSON API身份验证与PHP Curl

WordPress JSON API身份验证与PHP Curl,php,wordpress,wordpress-rest-api,Php,Wordpress,Wordpress Rest Api,我正在使用wordpress并使用这个插件https://wordpress.org/plugins/json-api-auth/对于JSON API Auth,我试图用PHP中的curl返回成功,但每当我运行代码时,我都会得到{“状态”:“错误”,“错误”:“无效的用户名和\/或密码”。} 从cURL url查询字符串中删除“about”。处理您的请求的WordPress PHP会将您的用户名读取为“abcd”,而不是您试图实现的abcd CURLOPT_URL=>'https://examp

我正在使用wordpress并使用这个插件
https://wordpress.org/plugins/json-api-auth/
对于JSON API Auth,我试图用PHP中的curl返回成功,但每当我运行代码时,我都会得到
{“状态”:“错误”,“错误”:“无效的用户名和\/或密码”。}

从cURL url查询字符串中删除“about”。处理您的请求的WordPress PHP会将您的用户名读取为
“abcd”
,而不是您试图实现的
abcd


CURLOPT_URL=>'https://example.com/api/auth/generate_auth_cookie/?username=“abcd”&password=“abcd”'
应该是


CURLOPT_URL=>'https://example.com/api/auth/generate_auth_cookie/?username=abcd&password=abcd'

我已经编辑了这个问题,你能在问题的底部检查一下吗?@Thor你的url中仍然有不应该出现的双引号。
CURLOPT\u url=>'https://example.com/api/auth/generate_auth_cookie/?username=“.$this->input->post('email')。&password=”。$this->input->post('password'))
如@Jonnix所述,我已经为您删除了那些双引号。
<?php
    $curl = curl_init();
    
    curl_setopt_array($curl, array(
    CURLOPT_URL => 'https://example.com/api/auth/generate_auth_cookie/?username="abcd"&password="abcd"',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "GET",
    ));
    
    $response = curl_exec($curl);
    
    curl_close($curl);
    echo $response;
?>
CURLOPT_URL => 'https://example.com/api/auth/generate_auth_cookie/?username="'.$this->input->post('email').'"&password="'.$this->input->post('password').'"',