These forums have been archived and are now read-only.

The new forums are live and can be found at https://forums.eveonline.com/

EVE Technology Lab

 
  • Topic is locked indefinitely.
 

Esi Mail Curl help..

Author
Geuthur
Voices of War - Research and Production
Sigma Grindset
#1 - 2017-02-15 19:29:22 UTC  |  Edited by: Geuthur
Hello,

I have some Problem i scriptet a php script but it doesnt work ....


session_start();

$cost = 0;
$body = 'Test';
$rid = '94547377';
$rtype = 'characters';
$sub = 'test object';
$auth_code = '';

function curl_post_group()
{
    $ch = curl_init();
    $url = 'https://esi.tech.ccp.is/latest/characters/94547377/mail/?datasource=tranquility';
    curl_setopt($ch, CURLOPT_URL, $url);
    $header = 'Authorization: Bearer ' . $auth_code;
    // headers
    curl_setopt($ch, CURLOPT_HTTPHEADER,  array($headers));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
    curl_setopt($ch, CURLOPT_POST, true);
    $post ["approved_cost"] = $cost;
    $post ["body"] = $body;
    $post ["recipients"] = array();
    $post ["recipients"] ["recipient_id"] = $rid;
    $post ["recipients"] ["recipient_type"] = $rtype;
    $post ["subject"] = $sub;
    $post = json_encode($post, JSON_UNESCAPED_UNICODE);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
    curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
    curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/cacert.pem');
    $response = curl_exec($ch);
  $response = curl_exec($ch);
    if (curl_getinfo($ch) ["http_code"] != 201) {
        echo "Error";
        echo " HTTP_CODE:" . curl_getinfo($ch) ["http_code"];
        print_r(curl_getinfo($ch));
        print_r($response);
    }
    curl_close($ch);
    $response = json_decode($response);
    return $response;
}
curl_post_group();


thats the error i recieve

{"error": "'recipients' is required, 'subject' is required, 'body' is required, 'mail' is required"}
Geuthur
Voices of War - Research and Production
Sigma Grindset
#2 - 2017-02-16 14:41:22 UTC  |  Edited by: Geuthur
...
Daneel Trevize
Give my 11percent back
#3 - 2017-02-19 15:03:14 UTC
You're calling your function without passing in any parameters for $cost, etc. I'm not sure if they're in scope or not, but you should refactor it to not assume they are.

You're calling $response = curl_exec($ch); twice.
David Davaham
Deep Blue Logistics
#4 - 2017-02-21 01:21:26 UTC
Cleaned if up a little bit. Hopefully this helps. Good Luck


http://pastebin.com/4Y2ApSjc

Developer of EVEmail

qu1ckkkk
The Warp Core Stabilizers
#5 - 2017-02-21 05:41:43 UTC
You could have a look at Eseye to make these calls to ESI as wellI. An example can be seen here: https://github.com/eveseat/eseye/wiki/Open-a-New-Mail-Window-in-the-EVE-Client#full-script-example

Proud developer of SeAT! A Simple Eve API & Corporation Management Tool.

Project Page: https://github.com/eveseat/seat