I have not made WordPress http request before this. I did it first time and I am not getting the return response. It seems the response is not the intended as the API I am using, there the documentation depicts some parameters we can get in return, but I cant find any of those parameter in the response.
Here is my test code:
$response1 = wp_remote_get('https://api.duoservers.com/?auth_usernme=theapiusername&auth_password=theapipassword§ion=products&command=get_plans');
print_r($response1);
The above code generating the following output:
( [headers] => Array ( [server] => nginx [date] => Wed, 22 Jun 2016 08:34:50 GMT [content-type] => text/html; charset=UTF-8 [content-length] => 182 [connection] => close [vary] => Accept-Encoding [content-encoding] => gzip ) [body] => 0 1 0.017 s 0.004 s 6079653986 0 [response] => Array ( [code] => 200 [message] => OK ) [cookies] => Array ( ) [filename] => ) 0 1 0.016 s 0.005 s 6687868871 0
Can someone please explain what does the above response actually mean?
This is my first time using WordPress HTTP request sending, so I am quite confused.
It is an array. It provides information on how the data is sent. Look at the [headers] and you'll find information about the content-type, the charset, the connection etc.. The [headers][content-type] for instance indicates on how you can proceed with the information. And then the [body], the actual content, that you probably will use in some way. You can read it better, if you output like this:
echo '<pre>';
print_r($resonse1); //you can also use var_dump()
echo '</pre>';
You can for instance just retrieve the [body]:
$bodyX = $response1['body'];
You can, as before, print the result:
echo '<pre>';
print_r($bodyX); //you can also use var_dump()
echo '</pre>';
Good luck.