Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for submitting multiple recipients to a list simultaneously. #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kander-zz
Copy link

Hi NeoSeekers - thanks for putting in the work to make this library PSR-0 compliant and Composer-loadable. Much appreciated!

Yesterday I spent some time working with SendGrid Support, trying to find out how I could load multiple users into a recipient list simultaneously. This is documented in the Newsletter API Documentation, under the curl examples.

Problem is that SendGrid wants us to submit the same parameter multiple times (data[]). Using numeric indexes in the array does not work, so what I ended up doing is manually building up the HTTP PostData querystring.

@redemption
Copy link

Hi Kander,

Thanks for the pull request. Just curious, is there a reason to rewrite postData in Connect rather than Newsletter, where it would be less likely to affect other calls?

@kander-zz
Copy link
Author

Hi @redemption - I've wrestled with that for some time before settling on doing it in the Connect class.

Connect::makeApiCall() assumes that the incoming $postData is an array, so it can add the username/password variables. If I were to do the encoding in Newsletter, that would mean doing either a copy-past re-implementation of makeApiCall, or add some magical flag indicating that the content was querystring-encoded already, and let Newsletter take on additional responsibility of injecting the user credentials.

On the other hand, Curl will have to do some form of http_build_query() internally to convert the array to a query string anyway, so the implementation should not be affected. And if SendGrid chooses to use this method for sending a collection of values, they're probably going to be consistent and do it this way in any other place that might need a collection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants