I'm trying to convert this php code to the wordpress wp_remote_post() format. Thoughts, Ideas, This is NOT my forte, lol.
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://xxxx.yyyyy.zzzzz');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'x-api-key' => 'ppppppppppppppp',
'Content-Type' => 'application/json'
));
$request->setBody('{\n "object_type": "Leaderboard",\n "action": "list",\n "pagination": {\n "limit": 5,\n "order": false\n },\n "data": {\n "username": "me@mysite.me"\n }\n}');
try {
$response = $request->send();
if ($response->getStatus() == 200) {
echo $response->getBody();
}
else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
}
catch(HTTP_Request2_Exception $e) {
echo 'Error: ' . $e->getMessage();
}