Created
October 17, 2013 04:06
-
-
Save sebmih/7019088 to your computer and use it in GitHub Desktop.
A working PHP script that adds multiple addresses for the ME API.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$username='SG_username'; | |
$password='SG_password'; | |
$url = 'https://sendgrid.com/api/newsletter/lists/email/add.json?api_user='.$username.'&api_key='.$password; | |
// API call including username and password | |
$email=array('email@domain.com','mail@example.com','mailz@email.com'); | |
//initialize the email array | |
$name=array('Name1','Name2','Name3'); | |
//initialize the name array | |
$listname='name_of_recipient_list'; | |
$str= '&list=' . $listname; | |
//concatenate the original URL with the listname | |
for ($i=0;$i<count($email);$i++) { | |
$str.= '&data[]={"email":"'.$email[$i] . '","name":"'.$name[$i].'"}'; | |
} | |
echo $url.$str; | |
$api=file_get_contents($url . $str); | |
// run the API call | |
echo $api; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment