php-sparkpost | SparkPost client library for PHP | REST library
kandi X-RAY | php-sparkpost Summary
kandi X-RAY | php-sparkpost Summary
The official PHP library for using the SparkPost REST API. Before using this library, you must have a valid API Key. To get an API Key, please log in to your SparkPost account and generate one in the Settings page.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Build request parameters
- Set the options
- Add list to recipients
- Convert an address to an object .
- Set the promise and return the response .
- Wait for promise .
- Return a new response with the given body .
- Get Headers
- Get the response body
- Get the current request
php-sparkpost Key Features
php-sparkpost Examples and Code Snippets
Community Discussions
Trending Discussions on php-sparkpost
QUESTION
I've successfully used the PHP transmissions endpoint in Sparkpost PHP API https://github.com/SparkPost/php-sparkpost#send-an-email-using-the-transmissions-endpoint with https://github.com/SparkPost/php-sparkpost#wait-synchronous but now I need to send two different emails to two different addresses, at the same point in my program.
Seemed like the obvious way was to use the asynchronous method https://github.com/SparkPost/php-sparkpost#then-asynchronous but I can't get this working with the post endpoint. Code below.
Or is there a better way? I wasn't sure how to make the synchronous code do two separate requests one after the other.
...ANSWER
Answered 2018-Sep-20 at 08:22You've defined handlers for promise fulfillment and rejection. But the promise requires to be fulfilled or rejected to invoke the handlers.
Since you're waiting for response from SparkPost, you need to wait()
on the promise object.
$promise1->wait();
$promise2->wait();
Read last line in Then (Asynchronous) Section of SparkPost Reference.
Also, if you're planning for multiple promises then you may use \GuzzleHttp\Promise\all()
to combine all promises ( as suggested in second last line of same section )
QUESTION
I can´t get my head around syntax on line 25 in this SparkPost code - link on github What if I want to add an additional variable to this?
...ANSWER
Answered 2017-Aug-03 at 11:51substitution_data
is an arbitrary list of key/value pairs you can supply and then use in your content or template. In PHP you pass in substitution_data
as an associative array. To add more items to it you can do this:
QUESTION
I'm using the example from https://github.com/SparkPost/php-sparkpost#send-an-email-using-the-transmissions-endpoint
with the asynch promise here: https://github.com/SparkPost/php-sparkpost#then-asynchronous
Everything is installed properly using Composer. If I use $response = $promise->wait(); email is sent but not $promise->then(function(){}, function(){})
I'm running php script from command line, asynch option set to true
...ANSWER
Answered 2018-Mar-12 at 14:07There is a mistake (or just an bad assumption) in the SparkPost docs.
You have to call ->wait()
somehow anyway. So just add $promise->wait();
in the end of your second script, and it'll be fine.
By "somehow" I mean that you can combine promises together using all()
, some()
and other functions.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install php-sparkpost
Because of dependency collision, we have opted to use a request adapter rather than requiring a request library. This means that your application will need to pass in a request adapter to the constructor of the SparkPost Library. We use the HTTPlug in SparkPost. Please visit their repo for a list of supported clients and adapters. If you don't currently use a request library, you will need to require one and create a client from it and pass it along. The example below uses the GuzzleHttp Client Library.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page