cURL vs wp_remote_X
-
Heya,
right now, I’m trying to develop my first plugin.
Because WordPress comes with its own HTTP-API, I want to switch from cURL (script was used as stand alone) to wp_remote_X, but I’m stuck and need your help.While
$ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: ' . $apikey, 'Accept: application/vnd.api+json')); curl_setopt($ch, CURLOPT_URL,$url); $result=curl_exec($ch); curl_close($ch);
is working fine, I cannot “translate” it to the new wp_remote-thing:
$result = wp_remote_retrieve_body(wp_remote_get($url, array('sslverify' => false, 'headers' => array('Authorization: '. $apikey,'Accept: application/vnd.api+json'))));
Result should be some JSON data, but I always get a 451 – Unsupported Media Type
Hope you guys here can help me.
Thanks a lot!
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘cURL vs wp_remote_X’ is closed to new replies.