Chabniest
(Chabniest)
April 28, 2019, 3:18pm
1
Hi,
I have the problem, that my PHP code seems not so right and I come not to a sollution. Maybe someone can help me with my problem.
I want to mark a ingame mail as read with a curl request but it doesn’t work. there are no errors appear.
The code before works fine. My only problem ist the PUT request to mark the mail as read.
Has anybody an idea?
thanks
Here is my code:
$post_field = array(“read” => “true”);
$ch8 = curl_init();
$lookup_url8=“https://esi.evetech.net/latest/characters/".$char_id."/mail/".$mail_id_api."/?datasource=tranquility ”;
$header8='Authorization: Bearer '.$auth_token;
curl_setopt($ch8, CURLOPT_URL, $lookup_url8);
curl_setopt($ch8, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch8, CURLOPT_HTTPHEADER, array($header8));
curl_setopt($ch8, CURLOPT_CUSTOMREQUEST, “PUT”);
curl_setopt($ch8, CURLOPT_POSTFIELDS, http_build_query($post_field));
curl_setopt($ch8, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch8, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch8, CURLOPT_SSL_VERIFYHOST, 2);
$result8 = curl_exec($ch8);
curl_close($ch8);
$response8=json_decode($result8);
What’s the error tho? It could just be your token doesn’t have the required scope to do this. i.e. is missing esi-mail.organize_mail.v1
.
Also not sure if it would matter but it should be a boolean not string, i.e. $post_fields = ['read' => true];
http_build_query
would create a URL-encoded query string, when the body should be JSON.
Chabniest
(Chabniest)
April 28, 2019, 4:27pm
3
Thanks for your answer.
This is not the solution. The mail is still marked as unread.
So I found a solution:
$ch9 = curl_init();
$lookup_url9=“https://esi.evetech.net/latest/characters/".$char_id."/mail/".$mail_id_api."/?datasource=tranquility ”;
$header9 = array();
$header9 = ‘Accept: application/json’;
$header9 ='Authorization: Bearer '.$auth_token;
$header9 = ‘Content-Type: application/json’;
curl_setopt($ch9, CURLOPT_URL, $lookup_url9);
curl_setopt($ch9, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch9, CURLOPT_HTTPHEADER, $header9);
curl_setopt($ch9, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch9, CURLOPT_POSTFIELDS, “{ “read”: true}”);
curl_setopt($ch9, CURLOPT_CUSTOMREQUEST, ‘PUT’);
curl_setopt($ch9, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch9, CURLOPT_SSL_VERIFYHOST, 2);
$result9 = curl_exec($ch9);
curl_close($ch9);
$response9=json_decode($result9);
This would work as well
<?php
const TOKEN = 'YOUR_TOKEN';
const CHAR_ID = 1234;
const MAIL_ID = 5678;
const URL = 'https://esi.evetech.net/latest/characters/' . CHAR_ID . '/mail/' . MAIL_ID . '/';
$ch8 = curl_init();
$header='Authorization: Bearer '.TOKEN;
curl_setopt($ch8, CURLOPT_URL, URL);
curl_setopt($ch8, CURLOPT_HTTPHEADER, array($header));
curl_setopt($ch8, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch8, CURLOPT_POSTFIELDS, json_encode(['read' => true]));
curl_setopt($ch8, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch8, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch8, CURLOPT_SSL_VERIFYHOST, 2);
$result8 = curl_exec($ch8);
curl_close($ch8);
$response8=json_decode($result8);
From what i could tell your quotes were not really quotes and you have to give it a JSON body.
system1
(system)
Closed
July 27, 2019, 5:44pm
6
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.