I use Autoresponder plugin for sending welcome email while installing Shopify Application.
I use RESTAPI
- login
- subscriberAdd
- listSubscriberAdd
and adding subscriber into the particular list.
When I using these API from POSTMAN it will be working fine.
- Login API
Parameter :
login:
pasdsword:
- SubscriberAdd API
Parameter :
email:xyz@yopmail.com
confirmed:1
htmlemail:1
foreignkey:
subscribepage:
password:
disabled:
- listSubscriberAdd API
Parameter :
list_id:2
subscriber_id:18 (dynamic generated subscriber_id)
When I use postman it will send mail successfully and it set already sent = 1 (mail already sent)
Subscribers ready | not ready | already sent => 0 | 0 | 1.
But using the Shopify-Laravel code adding subscriber into the particular list but not send an email.
But using these code it only set Subscribers ready | not ready | already sent => 1 | 0 | 0.
I am trying to send welcome mail while installing Shopify App. this is my shopify-laravel code
/* PHPLIST START */
$subpost_params = 'cmd=login&login=admin&password=********&cmd=listSubscribers&list_id=2';
$GetSubscruberAPIs = $sh->callApi($subpost_params);
$email_array = array();
foreach ($GetSubscruberAPIs->data as $key => $data) {
$email_array[] = $data->email;
}
if (!in_array("vijay2244@yopmail.com", $email_array)) {
$post_params ='cmd=login&login=admin&password=****************&cmd=subscriberAdd&email=vijay2244@yopmail.com&confirmed=1&htmlemail=1';
$LoginAPIs = $sh->callApi($post_params);
if ($LoginAPIs->data->id != '') {
$post_params1 = 'cmd=login&login=admin&password=************&cmd=listSubscriberAdd&list_id=2&subscriber_id=' . $LoginAPIs->data->id;
$LoginAPIs1 = $sh->callApi($post_params1);
}
}
/* PHPLIST END */
This is my function for CURL
public function callApi($post_params, $decode = true) {
// Serialise and encode query
$service_url = 'http://xyz.com/lists/admin/?page=call&pi=restapi';
// Prepare cURL
$c = curl_init();
curl_setopt($c, CURLOPT_URL, $service_url);
curl_setopt($c, CURLOPT_HEADER, 0);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_POST, 1);
curl_setopt($c, CURLOPT_POSTFIELDS, $post_params);
$result = curl_exec($c);
if (curl_errno($c)) {
print "Error: " . curl_error($c) . PHP_EOL;
}
// Check if decoding of result is required
if ($decode === true) {
$result = json_decode($result);
}
//echo "<pre>";print_r($result);die;
return $result;
}
Using these code adding subscriber into the particular list. but Autoresponder status
Subscribers ready | not ready | already sent => 1 | 0 | 0.
it never set already sent = 1 (mail already sent)
When I use postman it will send mail successfully and it set already sent = 1 (mail already sent)
Subscribers ready | not ready | already sent => 0 | 0 | 1.
But using these code it only set Subscribers ready | not ready | already sent => 1 | 0 | 0.
And Manually send campaigns from PHPList software it will be working fine.
Subscribers ready | not ready | already sent => 0 | 0 | 1.