Hello Capuleers,
Im trying something relatively easy but im missing something. Im trying to set a waypoint for a character where i have the accessToken for. Bottom is my code but im getting the error
{"error":"'add_to_beginning' is required, 'clear_other_waypoints' is required, 'destination_id' is required"}
This is the code that i have for it, the curl works for the authorization codes perfectly.
public function setWaypoint($accessToken, $destination) {
$url = ESIURL."ui/autopilot/waypoint/";
$header = 'Authorization: Bearer '.$accessToken;
$fields = array (
'add_to_beginning' => 'true',
'clear_other_waypoints' => 'true',
'destination_id' => (string)$destination
);
if($result = CURL::execute($url, $header, $fields)) {
return $result;
} else {
return false;
}
And the curl function:
public static function execute($url, $header = null, $fields = null) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, CRESTUserAgent); # Defined in config
if($header != null) {
curl_setopt($ch, CURLOPT_HTTPHEADER, array($header));
}
# If fields need to be send aswell
if($fields != null) {
curl_setopt($ch, CURLOPT_POST, count($fields));
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields));
}
curl_setopt($ch, CURLOPT_ENCODING, ''); # Enable Gzip
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 ); # Only do ipv4
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
$result = curl_exec($ch);
return $result;
}
Note: im just a hobby ‘programmer’ and any help is appreciated! Thanks in advance