mailjet / mailjet-apiv3-php-simple

[API v3] Simple PHP wrapper for the Mailjet API /!\ [DEPRECATED - SEE README] /!\
https://dev.mailjet.com
MIT License
55 stars 45 forks source link

response code 400 with empty response #132

Closed ovaisbawany closed 7 years ago

ovaisbawany commented 7 years ago

I am using curl to request a simple mail sending api call. It returns me 400 (bad request) with no response. Can anyone help me that what I am doing wrong in the request ?

$curl = curl_init();
        $data = [
            CURLOPT_RETURNTRANSFER => true,
            CURLINFO_HEADER_OUT => true,
            CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
            CURLOPT_URL => "https://api.mailjet.com/v3/send",
            CURLOPT_USERPWD => "APIKEY:APISECRET",
            CURLOPT_POST => 1,
            CURLOPT_HTTPHEADER => array('Content-Type:application/json'),
            CURLOPT_POSTFIELDS => $body,
        ];

        curl_setopt_array($curl, $data);
       $response = curl_exec($curl);

curl_getinfo($curl) returns

[url] => https://api.mailjet.com/v3/send
    [content_type] => text/html
    [http_code] => 400
    [header_size] => 211
    [request_size] => 299
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 0
    [total_time] => 2.297
    [namelookup_time] => 0.266
    [connect_time] => 0.688
    [pretransfer_time] => 1.485
    [size_upload] => 2145
    [size_download] => 0
    [speed_download] => 0
    [speed_upload] => 933
    [download_content_length] => 0
    [upload_content_length] => 2145
    [starttransfer_time] => 1.891
    [redirect_time] => 0
    [redirect_url] => 
    [primary_ip] => 35.187.79.8
    [certinfo] => Array
        (
        )

    [primary_port] => 443
    [local_ip] => 192.168.4.105
    [local_port] => 1322
    [request_header] => POST /v3/send HTTP/1.1
Host: api.mailjet.com
Authorization: Basic [Auth Code here]
Accept: */*
Content-Length: 2145
Expect: 100-continue
Content-Type:application/json; boundary=------------------------61367fe6d369bd5a
Zhivko-Mailjet commented 7 years ago

@ovaisbawany Please note that the php-simple is considered deprecated and is not maintained anymore. Please consider using our up-to-date PHP wrapper

If for some reasons you should stick with this version, please provide some details and the $body of the API call in a support ticket and we will do our best to help.

ovaisbawany commented 7 years ago

Thanks Zhivko-Mailjet for the response, I used PHP wrapper and my problem got resolved. Thanks again.