Coder Social home page Coder Social logo

sendgrid-php-library's People

Contributors

alonbendavid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

sendgrid-php-library's Issues

sendgridConnect::TIMEOUT is too short

The default 20-second timeout is too short for some operations to complete, such as newsletter_get_list_emails() on a list with > 15k addresses.

I'd suggest lengthening the timeout, or making it configurable on a per-request basis.

No HTTP errors handling

I've got a problem with SSL CA but this library didn't catch that and kept returning empty string.
This isn't good, I think the library should check HTTP response code. I updated code a little, please review the following patch:

% cat sendgrid.patch 
# This patch file was generated by NetBeans IDE
# Following Index: paths are relative to: libraries/SendGrid-PHP-Library/sendgrid/core
# This patch can be applied using context Tools: Patch action on respective folder.
# It uses platform neutral UTF-8 encoding and \n newlines.
# Above lines and this line are ignored by the patching process.
Index: sendgrid-connect.php
--- sendgrid-connect.php Base (BASE)
+++ sendgrid-connect.php Locally Modified (Based On LOCAL)
@@ -55,7 +55,7 @@
     * sendgrid endpoint ...
     * @var string
     */
-   const SG_ENDPOINT = 'https://sendgrid.com/api';
+   const SG_ENDPOINT = 'https://api.sendgrid.com/api';
 
    /**
     * Creates a new SendGrid Newsletter API object to make calls with
@@ -119,8 +119,10 @@
 
        // obtain response
        $jsonResponse = curl_exec($session);
-       curl_close($session);
-       
+       $http_code = curl_getinfo($session, CURLINFO_HTTP_CODE);
+       if ($http_code != 200) {
+           $this->lastResponseError = curl_error($session);
+       } else {
        $this->debugCall('DEBUG - Json Response: ' , $jsonResponse);
        
        $results  = json_decode ( $jsonResponse, TRUE );
@@ -128,6 +130,8 @@
        $this->debugCall('DEBUG - Results: ' , $results);
        
        $this->lastResponseError = isset($results['error']) ? $results['error'] : NULL;
+        }
+       curl_close($session);
 
        return $this->lastResponseError ? false : $results;
    }

Also please note that SG API has new URL.

PS: after these changes I finally found a reason why my stopped communicating with SG: "Problem with the SSL CA cert (path? access rights?)"

your library is broken

hi, the api calls against sendgrid newsletter api don't work. you have a bad endpoint and do not distinguish between get and post requests. i think you want to check that.

and by the way, your coding style is terrible.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.