How to add multiple contacts at a single call through Getresponse api - php

I am trying to add subscriber to list through Getresponse api for single contact subscription to list i have to call api like this
$getresponse = new GetResponse(api key);
$result = $getresponse->addContact(listid,
$lead['name'],
$lead['email']
);
Now i want to add multiple emails at a single call, i cant use foreach loop for each contact, is there a function or endpoint to add multiple emails at a single call?

Getresponse official API shows only one contact.
https://apidocs.getresponse.com/v3/resources/contacts#contacts.create
As of now, there is no API endpoints for import contacts as bulk (csv or JSON).

Yes, Bala is correct. There is no such API method for GetResponse to insert multiple contacts. However, please check the below API codes to insert single contact to GetResponse.
include('GetResponseAPI3.class.php');
$getresponse = new GetResponse('your-getresponse-token-here');
$var = $getresponse->addContact(array
(
'name' => 'FirstName LastName',
'email' => 'emailid#something.com',
'dayOfCycle' => 0,
'campaign' => array('campaignId' => 'Campaign-id'),
'ipAddress' => 'XXX.XXX.XX.XX'
)
);
var_dump($var);

Related

Sending notification to 25k+ users causing problem on backend

There is currently 25k+ users we have in database. All users are subscribed to a common topic All.
I have two directories inside public_html. First is for API built in codeigniter. This API is used to provide data for all adnroid and iOS devices.
Second directory is for admin panel built in Laravel. We use it to upload data and also to send notification to firebase topics.
Both API and Admin Panel share same database.
If we send notification to topics which is not subscribed by much
users, there is no issue. But If I send notificaiton to a topic
which has much users It causes problems on our backend. The API
stops responding, or sometimes takes too long to respond.
Sometimes also admin panel stops responding too.
I am so confused because all the things are handled by firebase. I just make one API call.
Can anyone explain what's causing the problem?
Or any possible reason?
Update
use Kreait\Firebase\Messaging;
use Illuminate/Support/Http/Request;
trait UserTrait {
public function notify(Request $request, Messaging $messaging) {
$message_hi = array(
"notification_type" => $notification_type,
"notification_title" => $notification_title_hi,
"icon_image" => $icon_image,
"notification_description" => $request->notificationText_hi,
"image_url" => $request->image_url,
);
$message = array(
"notification_type" => $notification_type,
"notification_title" => $notification_title,
"icon_image" => $icon_image,
"notification_description" => $request->notificationText,
"image_url" => $request->image_url,
);
$commodityIdArray = $request->cId
//to send all
if($request->notification_type == 1) {
$messaging->sendAll([
['topic' => 'All', 'data' => $message],
['topic' => 'All_hi', 'data' => $message_hi],
]);
} else {
//to send to a fourite topic subscribed by some users
//Prepare Condition for both hindi and english users
$topic_condition = "";
$topic_condition_hi = "";
foreach($commodityIdArray as $topic) {
$topic_condition .="'".$topic."' in topics && ";
$topic_condition_hi.="'".$topic."_hi' in topics &&";
}
//send notification to hindi and english topics
$messaging->sendAll([
['condition' => substr($topic_condition, 0, -3), 'data' =>
$message],
['condition' => substr($topic_condition_hi, 0, -3), 'data' =>
$message_hi],
]);
}
}
Use Queue
You have to use a Queue which set your process in queue and when one process completes, the second one starts
you can also set number of retries of your process

Send eth programmatically php

I use https://github.com/coinbase/coinbase-php with laravel to send Eth from my wallet to wallet on other service.
I use this method: $client->createAccountTransaction($account, $transaction);
In this way:
$transaction = Transaction::send([
'to' => new EthrereumAddress($destination_address),
'amount' => new Money($amount, $currency),
'description' => $description,
//'fee' => '0.0001' // only required for transactions under BTC0.0001
]);
$this->client->createAccountTransaction($account, $transaction);
But when I try to do this, I get this error:
The Coinbase API only accepts transactions to an account, email, or bitcoin address
Can someone tell me how to send eth or what is wrong ?
This was fixed in the latest 2.8.0 version.
https://github.com/coinbase/coinbase-php/releases/tag/2.8.0
You should use right $account for each cryptocurrency, but not just the $client->getPrimaryAccount();
For example:
$account = Account::reference('YOUR_ETH_ACCOUNT_ID');

Mailchimp for WP add subscriber programmatically

i am trying to add an user to a MailChimp list programmatically (so he is a subscriber of any emails i will send).
I do have the pro-version of the MailChimp for WordPress plugin.
Is there a way to add - and remove a user (Email and three fields) to a list dynamically?
There seems to be an API (http://developer.mc4wp.com/), but i did not found a function to do so.
Is there one?
Use the mc4wp_get_api function to grab an instance of the MailChimp for WordPress API. Then call the subscribe() function add an email to a list:
$list_id = "2341ca4321";
$email = "subscriber#email.com";
$api = mc4wp_get_api();
$api->subscribe($list_id, $email);
The subscribe() function returns a boolean. This return value simply reports if the subscribe request succeeded. Will return false if the user is already on the list
$list_id can be found when logged into MailChimp, looking under a list, Settings > List name and campaign defaults > List ID
include('/MailChimp.php');
$MailChimp = new \DrewM\MailChimp\MailChimp("API-KEY");
$result = $MailChimp->get('lists');
$list_id = 'a0123a45f'; // List Key
$result = $MailChimp->post("lists/$list_id/members", [
'email_address' => test#test.com,
'status' => 'subscribed',
'merge_fields' => array('FNAME'=>'test', 'LNAME'=>'tester'),
]);

Get users details in mixpanel api

I'm trying to get user details via Mixpanel analytics but I am having difficulties to properly grasp how i should do this… data has been set using
mixpanel.people.identify()
Events and Segmentation requests seem to be ok; but I can't figure out how to query a request on the Engage endpoint.
as it turns out—there might be other ways to find this out but this one works for me:
you need to get engagement data this way
$data = $mp->request(array('engage'));
foreach($data->results as $user) {
$email = $user->{'$properties'}->{'$email'};
$last_seen_date = $user->{'$properties'}->{'$last_seen'};
$distinct_id = $user->{'$distinct_id'};
}
the distinct_id can then be used within the foreach() loop above to get events registered with this user:
$endpoint = array('stream', 'query');
$parameters = array(
'distinct_ids' => json_encode(array($distinct_id)),
'from_date' => '2014-02-10',
'to_date' => '2014-02-25',
);

Zendesk php api create ticket without sending email to the user?

I am trying to create tickets on my Zendesk and that is working fine. However i do not want Zendesk to email the creator of the tickets (his or her email). Is this possible?
The idea is i have a contactForm widget on my site, i want the submits from this form to create tickets in my Zendesk.
Creating tickets is currently working using this code:
$zendesk = new zendesk(
$row->api_key,
$row->email_address,
$row->host_address,
$suffix = '.json',
$test = false
);
$arr = array(
"z_subject"=>"Offline Message",
"z_description"=> $r->contact_msg,
"z_recipient"=>$r->contact_email,
"z_name"=>$r->contact_name,
);
$create = json_encode(
array('ticket' => array(
'subject' => $arr['z_subject'],
'description' => $arr['z_description'],
'requester' => array('name' => $arr['z_name'],
'email' => $arr['z_requester']
))),
JSON_FORCE_OBJECT
);
$data = $zendesk->call("/tickets", $create, "POST");
Any ideas?
Totally possible! You need to add some conditions to the trigger "Notify requester of received request" in Zendesk - Trigger setting to prevent zendesk from sending email. For ex:
Ticket : Channel - Is Not - Webservice (API)
Ticket : Tags - Contains one of the following - "offline message"
You could use another API endpoint "Ticket Import" https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_import/
It's do not send notifications

Categories