admin管理员组文章数量:1327679
I created a plug-in that retrieves data from an api(at least tries to!). This is the code of the function.
function call_back(){
$apiKey = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$response = wp_remote_get ('',$args);
$args = array(
'headers' => array(
'Content-Type' => 'application/json',
'Authorization' => 'Basic ', $apiKey,
)
);
echo '<pre>';
var_dump(wp_remote_retrieve_body($response));
echo '</pre>';
};
The api key that i use works, used it in postman. But the problem i get is that in WP i get:
"string(95) "{"errorMessages":["Issue does not exist or you do not have permission to see it."],"errors":{}}""
I do have permission and the issue does exist, the problem is with authentication. For some reason i don't get access. Any idea on why?
I created a plug-in that retrieves data from an api(at least tries to!). This is the code of the function.
function call_back(){
$apiKey = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$response = wp_remote_get ('http://mysite.atlassian/rest/api/3/issue/LD-1',$args);
$args = array(
'headers' => array(
'Content-Type' => 'application/json',
'Authorization' => 'Basic ', $apiKey,
)
);
echo '<pre>';
var_dump(wp_remote_retrieve_body($response));
echo '</pre>';
};
The api key that i use works, used it in postman. But the problem i get is that in WP i get:
"string(95) "{"errorMessages":["Issue does not exist or you do not have permission to see it."],"errors":{}}""
I do have permission and the issue does exist, the problem is with authentication. For some reason i don't get access. Any idea on why?
Share Improve this question edited Jul 30, 2020 at 0:16 Jacob Peattie 44.1k10 gold badges50 silver badges64 bronze badges asked Jul 29, 2020 at 15:33 ThinsantaThinsanta 112 bronze badges 2 |1 Answer
Reset to default 1Thank you that helped me alot! But there was one more problem and that was the "'Authorization' => 'Basic ', $apiKey,"
part. I just needed a dot before $apiKey. Thanks again for your help!
本文标签: pluginsWhat am is missing (API CORS)
版权声明:本文标题:plugins - What am is missing? (API CORS) 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742221796a2435493.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
$args
first – fuxia ♦ Commented Jul 29, 2020 at 15:46