You are reading the REST API Code Examples. Click for the HTTP API.
Sending SMS Messages |
| Sends SMS text messages via the short code 313131 (393939 In Canada) to a single phone number or an array of phone numbers. |
Code Samples |
|
PHP - XML
<?php
$data = array(
'User' => 'winnie',
'Password' => 'the-pooh',
'PhoneNumbers' => array('2123456785', '2123456786', '2123456787', '2123456788'),
'Subject' => 'From Winnie',
'Message' => 'I am a Bear of Very Little Brain, and long words bother me',
'StampToSend' => '1305582245',
'MessageTypeID' => 1
);
$curl = curl_init('https://app.eztexting.com/sending/messages?format=xml');
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// If you experience SSL issues, perhaps due to an outdated SSL cert
// on your own server, try uncommenting the line below
// curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
curl_close($curl);
$xml = new SimpleXMLElement($response);
if ( 'Failure' == $xml->Status ) {
$errors = array();
foreach( $xml->Errors->children() as $error ) {
$errors[] = (string) $error;
}
echo 'Status: ' . $xml->Status . "\n" .
'Errors: ' . implode(', ' , $errors) . "\n";
} else {
$phoneNumbers = array();
foreach( $xml->Entry->PhoneNumbers->children() as $phoneNumber ) {
$phoneNumbers[] = (string) $phoneNumber;
}
$localOptOuts = array();
foreach( $xml->Entry->LocalOptOuts->children() as $phoneNumber ) {
$localOptOuts[] = (string) $phoneNumber;
}
$globalOptOuts = array();
foreach( $xml->Entry->GlobalOptOuts->children() as $phoneNumber ) {
$globalOptOuts[] = (string) $phoneNumber;
}
echo 'Status: ' . $xml->Status . "\n" .
'Message ID : ' . $xml->Entry->ID . "\n" .
'Subject: ' . $xml->Entry->Subject . "\n" .
'Message: ' . $xml->Entry->Message . "\n" .
'Message Type ID: ' . $xml->Entry->MessageTypeID . "\n" .
'Total Recipients: ' . $xml->Entry->RecipientsCount . "\n" .
'Credits Charged: ' . $xml->Entry->Credits . "\n" .
'Time To Send: ' . $xml->Entry->StampToSend . "\n" .
'Phone Numbers: ' . implode(', ' , $phoneNumbers) . "\n" .
'Locally Opted Out Numbers: ' . implode(', ' , $localOptOuts) . "\n" .
'Globally Opted Out Numbers: ' . implode(', ' , $globalOptOuts) . "\n";
}
?>
|
|
PHP - JSON
<?php
$data = array(
'User' => 'winnie',
'Password' => 'the-pooh',
'PhoneNumbers' => array('2123456785', '2123456786', '2123456787', '2123456788'),
'Subject' => 'From Winnie',
'Message' => 'I am a Bear of Very Little Brain, and long words bother me',
'StampToSend' => '1305582245',
'MessageTypeID' => 1
);
$curl = curl_init('https://app.eztexting.com/sending/messages?format=json');
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// If you experience SSL issues, perhaps due to an outdated SSL cert
// on your own server, try uncommenting the line below
// curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
curl_close($curl);
$json = json_decode($response);
$json = $json->Response;
if ( 'Failure' == $json->Status ) {
$errors = array();
if ( !empty($json->Errors) ) {
$errors = $json->Errors;
}
echo 'Status: ' . $json->Status . "\n" .
'Errors: ' . implode(', ' , $errors) . "\n";
} else {
$phoneNumbers = array();
if ( !empty($json->Entry->PhoneNumbers) ) {
$phoneNumbers = $json->Entry->PhoneNumbers;
}
$localOptOuts = array();
if ( !empty($json->Entry->LocalOptOuts) ) {
$localOptOuts = $json->Entry->LocalOptOuts;
}
$globalOptOuts = array();
if ( !empty($json->Entry->GlobalOptOuts) ) {
$globalOptOuts = $json->Entry->GlobalOptOuts;
}
echo 'Status: ' . $json->Status . "\n" .
'Message ID : ' . $json->Entry->ID . "\n" .
'Subject: ' . $json->Entry->Subject . "\n" .
'Message: ' . $json->Entry->Message . "\n" .
'Message Type ID: ' . $json->Entry->MessageTypeID . "\n" .
'Total Recipients: ' . $json->Entry->RecipientsCount . "\n" .
'Credits Charged: ' . $json->Entry->Credits . "\n" .
'Time To Send: ' . $json->Entry->StampToSend . "\n" .
'Phone Numbers: ' . implode(', ' , $phoneNumbers) . "\n" .
'Locally Opted Out Numbers: ' . implode(', ' , $localOptOuts) . "\n" .
'Globally Opted Out Numbers: ' . implode(', ' , $globalOptOuts) . "\n";
}
?>
|
Check Keyword Availability |
| Check whether a Keyword is available to rent on Ez Texting's short code. Please note, we will check availability for the country your account is set to. |
Code Samples |
|
PHP - XML
<?php
$data = array(
'User' => 'winnie',
'Password' => 'the-pooh',
'Keyword' => 'honey'
);
$curl = curl_init('https://app.eztexting.com/keywords/new?format=xml&' . http_build_query($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// If you experience SSL issues, perhaps due to an outdated SSL cert
// on your own server, try uncommenting the line below
// curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
curl_close($curl);
$xml = new SimpleXMLElement($response);
if ( 'Failure' == $xml->Status ) {
$errors = array();
foreach( $xml->Errors->children() as $error ) {
$errors[] = (string) $error;
}
echo 'Status: ' . $xml->Status . "\n" .
'Errors: ' . implode(', ' , $errors) . "\n";
} else {
echo 'Status: ' . $xml->Status . "\n" .
'Keyword: ' . $xml->Entry->Keyword . "\n" .
'Availability: ' . $xml->Entry->Available . "\n";
}
?> |
|
PHP - JSON
<?php
$data = array(
'User' => 'winnie',
'Password' => 'the-pooh',
'Keyword' => 'honey'
);
$curl = curl_init('https://app.eztexting.com/keywords/new?format=json&' . http_build_query($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// If you experience SSL issues, perhaps due to an outdated SSL cert
// on your own server, try uncommenting the line below
// curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
curl_close($curl);
$json = json_decode($response);
$json = $json->Response;
if ( 'Failure' == $json->Status ) {
$errors = array();
if ( !empty($json->Errors) ) {
$errors = $json->Errors;
}
echo 'Status: ' . $json->Status . "\n" .
'Errors: ' . implode(', ' , $errors) . "\n";
} else {
echo 'Status: ' . $json->Status . "\n" .
'Keyword: ' . $json->Entry->Keyword . "\n" .
'Availability: ' . (int) $json->Entry->Available . "\n";
}
?> |
Code Samples - Stored Card |
|
PHP - XML
<?php
$data = array(
'User' => 'winnie',
'Password' => 'the-pooh',
'Keyword' => 'honey',
'StoredCreditCard' => '1111'
);
$curl = curl_init('https://app.eztexting.com/keywords?format=xml');
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// If you experience SSL issues, perhaps due to an outdated SSL cert
// on your own server, try uncommenting the line below
// curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
curl_close($curl);
$xml = new SimpleXMLElement($response);
if ( 'Failure' == $xml->Status ) {
$errors = array();
foreach( $xml->Errors->children() as $error ) {
$errors[] = (string) $error;
}
echo 'Status: ' . $xml->Status . "\n" .
'Errors: ' . implode(', ' , $errors) . "\n";
} else {
$groups = array();
foreach( $xml->Entry->ContactGroupIDs->children() as $group ) {
$groups[] = (string) $group;
}
echo 'Status: ' . $xml->Status . "\n" .
'Keyword ID: ' . $xml->Entry->ID . "\n" .
'Keyword: ' . $xml->Entry->Keyword . "\n" .
'Is double opt-in enabled: ' . (int) $xml->Entry->EnableDoubleOptIn . "\n" .
'Confirm message: ' . $xml->Entry->ConfirmMessage . "\n" .
'Join message: ' . $xml->Entry->JoinMessage . "\n" .
'Forward email: ' . $xml->Entry->ForwardEmail . "\n" .
'Forward url: ' . $xml->Entry->ForwardUrl . "\n" .
'Groups: ' . implode(', ' , $groups) . "\n";
}
?>
|
|
PHP - JSON
<?php
$data = array(
'User' => 'winnie',
'Password' => 'the-pooh',
'Keyword' => 'honey',
'StoredCreditCard' => '1111'
);
$curl = curl_init('https://app.eztexting.com/keywords?format=json');
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// If you experience SSL issues, perhaps due to an outdated SSL cert
// on your own server, try uncommenting the line below
// curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
curl_close($curl);
$json = json_decode($response);
$json = $json->Response;
if ( 'Failure' == $json->Status ) {
$errors = array();
if ( !empty($json->Errors) ) {
$errors = $json->Errors;
}
echo 'Status: ' . $json->Status . "\n" .
'Errors: ' . implode(', ' , $errors) . "\n";
} else {
echo 'Status: ' . $json->Status . "\n" .
'Keyword ID: ' . $json->Entry->ID . "\n" .
'Keyword: ' . $json->Entry->Keyword . "\n" .
'Is double opt-in enabled: ' . (int) $json->Entry->EnableDoubleOptIn . "\n" .
'Confirm message: ' . $json->Entry->ConfirmMessage . "\n" .
'Join message: ' . $json->Entry->JoinMessage . "\n" .
'Forward email: ' . $json->Entry->ForwardEmail . "\n" .
'Forward url: ' . $json->Entry->ForwardUrl . "\n" .
'Groups: ' . implode(', ' , $json->Entry->ContactGroupIDs) . "\n";
}
?>
|
Code Samples - Non-Stored Card |
|
PHP - XML
<?php
$data = array(
'User' => 'winnie',
'Password' => 'the-pooh',
'Keyword' => 'honey',
'FirstName' => 'Winnie',
'LastName' => 'The Pooh',
'Street' => 'Hollow tree, under the name of Mr. Sanders',
'City' => 'Hundred Acre Woods',
'State' => 'New York',
'Zip' => '12345',
'Country' => 'US',
'CreditCardTypeID' => 'Visa',
'Number' => '4111111111111111',
'SecurityCode' => '123',
'ExpirationMonth' => '10',
'ExpirationYear' => '2017'
);
$curl = curl_init('https://app.eztexting.com/keywords?format=xml');
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// If you experience SSL issues, perhaps due to an outdated SSL cert
// on your own server, try uncommenting the line below
// curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
curl_close($curl);
$xml = new SimpleXMLElement($response);
if ( 'Failure' == $xml->Status ) {
$errors = array();
foreach( $xml->Errors->children() as $error ) {
$errors[] = (string) $error;
}
echo 'Status: ' . $xml->Status . "\n" .
'Errors: ' . implode(', ' , $errors) . "\n";
} else {
$groups = array();
foreach( $xml->Entry->ContactGroupIDs->children() as $group ) {
$groups[] = (string) $group;
}
echo 'Status: ' . $xml->Status . "\n" .
'Keyword ID: ' . $xml->Entry->ID . "\n" .
'Keyword: ' . $xml->Entry->Keyword . "\n" .
'Is double opt-in enabled: ' . (int) $xml->Entry->EnableDoubleOptIn . "\n" .
'Confirm message: ' . $xml->Entry->ConfirmMessage . "\n" .
'Join message: ' . $xml->Entry->JoinMessage . "\n" .
'Forward email: ' . $xml->Entry->ForwardEmail . "\n" .
'Forward url: ' . $xml->Entry->ForwardUrl . "\n" .
'Groups: ' . implode(', ' , $groups) . "\n";
}
?>
|
|
PHP - JSON
<?php
$data = array(
'User' => 'winnie',
'Password' => 'the-pooh',
'Keyword' => 'honey',
'FirstName' => 'Winnie',
'LastName' => 'The Pooh',
'Street' => 'Hollow tree, under the name of Mr. Sanders',
'City' => 'Hundred Acre Woods',
'State' => 'New York',
'Zip' => '12345',
'Country' => 'US',
'CreditCardTypeID' => 'Visa',
'Number' => '4111111111111111',
'SecurityCode' => '123',
'ExpirationMonth' => '10',
'ExpirationYear' => '2017'
);
$curl = curl_init('https://app.eztexting.com/keywords?format=json');
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// If you experience SSL issues, perhaps due to an outdated SSL cert
// on your own server, try uncommenting the line below
// curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
curl_close($curl);
$json = json_decode($response);
$json = $json->Response;
if ( 'Failure' == $json->Status ) {
$errors = array();
if ( !empty($json->Errors) ) {
$errors = $json->Errors;
}
echo 'Status: ' . $json->Status . "\n" .
'Errors: ' . implode(', ' , $errors) . "\n";
} else {
echo 'Status: ' . $json->Status . "\n" .
'Keyword ID: ' . $json->Entry->ID . "\n" .
'Keyword: ' . $json->Entry->Keyword . "\n" .
'Is double opt-in enabled: ' . (int) $json->Entry->EnableDoubleOptIn . "\n" .
'Confirm message: ' . $json->Entry->ConfirmMessage . "\n" .
'Join message: ' . $json->Entry->JoinMessage . "\n" .
'Forward email: ' . $json->Entry->ForwardEmail . "\n" .
'Forward url: ' . $json->Entry->ForwardUrl . "\n" .
'Groups: ' . implode(', ' , $json->Entry->ContactGroupIDs) . "\n";
}
?>
|
Setup A Keyword |
| Configures an active Keyword for use on Ez Texting's short code in the country your account is set to send messages to. |
Code Samples |
|
PHP - XML
<?php
$data = array(
'User' => 'winnie',
'Password' => 'the-pooh',
'EnableDoubleOptIn' => true,
'ConfirmMessage' => 'Reply Y to join our sweetest list',
'JoinMessage' => 'The only reason for being a bee that I know of, is to make honey. And the only reason for making honey, is so as I can eat it.',
'ForwardEmail' => 'honey@bear-alliance.co.uk',
'ForwardUrl' => 'http://bear-alliance.co.uk/honey-donations/',
'ContactGroupIDs' => array('honey lovers')
);
$curl = curl_init('https://app.eztexting.com/keywords/honey?format=xml');
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// If you experience SSL issues, perhaps due to an outdated SSL cert
// on your own server, try uncommenting the line below
// curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
curl_close($curl);
$xml = new SimpleXMLElement($response);
if ( 'Failure' == $xml->Status ) {
$errors = array();
foreach( $xml->Errors->children() as $error ) {
$errors[] = (string) $error;
}
echo 'Status: ' . $xml->Status . "\n" .
'Errors: ' . implode(', ' , $errors) . "\n";
} else {
$groups = array();
foreach( $xml->Entry->ContactGroupIDs->children() as $group ) {
$groups[] = (string) $group;
}
echo 'Status: ' . $xml->Status . "\n" .
'Keyword ID: ' . $xml->Entry->ID . "\n" .
'Keyword: ' . $xml->Entry->Keyword . "\n" .
'Is double opt-in enabled: ' . (int) $xml->Entry->EnableDoubleOptIn . "\n" .
'Confirm message: ' . $xml->Entry->ConfirmMessage . "\n" .
'Join message: ' . $xml->Entry->JoinMessage . "\n" .
'Forward email: ' . $xml->Entry->ForwardEmail . "\n" .
'Forward url: ' . $xml->Entry->ForwardUrl . "\n" .
'Groups: ' . implode(', ' , $groups) . "\n";
}
?>
|
|
PHP - JSON
<?php
$data = array(
'User' => 'winnie',
'Password' => 'the-pooh',
'EnableDoubleOptIn' => true,
'ConfirmMessage' => 'Reply Y to join our sweetest list',
'JoinMessage' => 'The only reason for being a bee that I know of, is to make honey. And the only reason for making honey, is so as I can eat it.',
'ForwardEmail' => 'honey@bear-alliance.co.uk',
'ForwardUrl' => 'http://bear-alliance.co.uk/honey-donations/',
'ContactGroupIDs' => array('honey lovers')
);
$curl = curl_init('https://app.eztexting.com/keywords/honey?format=json');
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// If you experience SSL issues, perhaps due to an outdated SSL cert
// on your own server, try uncommenting the line below
// curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
curl_close($curl);
$json = json_decode($response);
$json = $json->Response;
if ( 'Failure' == $json->Status ) {
$errors = array();
if ( !empty($json->Errors) ) {
$errors = $json->Errors;
}
echo 'Status: ' . $json->Status . "\n" .
'Errors: ' . implode(', ' , $errors) . "\n";
} else {
echo 'Status: ' . $json->Status . "\n" .
'Keyword ID: ' . $json->Entry->ID . "\n" .
'Keyword: ' . $json->Entry->Keyword . "\n" .
'Is double opt-in enabled: ' . (int) $json->Entry->EnableDoubleOptIn . "\n" .
'Confirm message: ' . $json->Entry->ConfirmMessage . "\n" .
'Join message: ' . $json->Entry->JoinMessage . "\n" .
'Forward email: ' . $json->Entry->ForwardEmail . "\n" .
'Forward url: ' . $json->Entry->ForwardUrl . "\n" .
'Groups: ' . implode(', ' , $json->Entry->ContactGroupIDs) . "\n";
}
?>
|
Cancel A Keyword |
Cancels an active Keyword on Ez Texting's short code in the country your account is set to send messages to. |
Code Samples |
|
PHP - XML
<?php
$data = array(
'User' => 'winnie',
'Password' => 'the-pooh'
);
$curl = curl_init('https://app.eztexting.com/keywords/honey?format=xml&_method=DELETE');
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// If you experience SSL issues, perhaps due to an outdated SSL cert
// on your own server, try uncommenting the line below
// curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
curl_close($curl);
if ( !empty($response) ) {
$xml = new SimpleXMLElement($response);
if ( 'Failure' == $xml->Status ) {
$errors = array();
foreach( $xml->Errors->children() as $error ) {
$errors[] = (string) $error;
}
echo 'Status: ' . $xml->Status . "\n" .
'Errors: ' . implode(', ' , $errors) . "\n";
}
} else {
echo 'Status: Success' . "\n";
}
?>
|
|
PHP - JSON
<?php
$data = array(
'User' => 'winnie',
'Password' => 'the-pooh'
);
$curl = curl_init('https://app.eztexting.com/keywords/honey?format=json&_method=DELETE');
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// If you experience SSL issues, perhaps due to an outdated SSL cert
// on your own server, try uncommenting the line below
// curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
curl_close($curl);
if ( !empty($response) ) {
$json = json_decode($response);
$json = $json->Response;
if ( 'Failure' == $json->Status ) {
$errors = array();
if ( !empty($json->Errors) ) {
$errors = $json->Errors;
}
echo 'Status: ' . $json->Status . "\n" .
'Errors: ' . implode(', ' , $errors) . "\n";
}
} else {
echo 'Status: Success' . "\n";
}
?>
|
Check Credit Balance |
Checks credit balances on your account. |
Code Samples |
|
PHP - XML
<?php
$data = array(
'User' => 'winnie',
'Password' => 'the-pooh'
);
$curl = curl_init('https://app.eztexting.com/billing/credits/get?format=xml&' . http_build_query($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// If you experience SSL issues, perhaps due to an outdated SSL cert
// on your own server, try uncommenting the line below
// curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
curl_close($curl);
$xml = new SimpleXMLElement($response);
if ( 'Failure' == $xml->Status ) {
$errors = array();
foreach( $xml->Errors->children() as $error ) {
$errors[] = (string) $error;
}
echo 'Status: ' . $xml->Status . "\n" .
'Errors: ' . implode(', ' , $errors) . "\n";
} else {
echo 'Status: ' . $xml->Status . "\n" .
'Plan credits: ' . $xml->Entry->PlanCredits . "\n" .
'Anytime credits: ' . $xml->Entry->AnytimeCredits . "\n" .
'Total: ' . $xml->Entry->TotalCredits . "\n";
}
?>
|
|
PHP - JSON
<?php
$data = array(
'User' => 'winnie',
'Password' => 'the-pooh'
);
$curl = curl_init('https://app.eztexting.com/billing/credits/get?format=json&' . http_build_query($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// If you experience SSL issues, perhaps due to an outdated SSL cert
// on your own server, try uncommenting the line below
// curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
curl_close($curl);
$json = json_decode($response);
$json = $json->Response;
if ( 'Failure' == $json->Status ) {
$errors = array();
if ( !empty($json->Errors) ) {
$errors = $json->Errors;
}
echo 'Status: ' . $json->Status . "\n" .
'Errors: ' . implode(', ' , $errors) . "\n";
} else {
echo 'Status: ' . $json->Status . "\n" .
'Plan credits: ' . $json->Entry->PlanCredits . "\n" .
'Anytime credits: ' . $json->Entry->AnytimeCredits . "\n" .
'Total: ' . $json->Entry->TotalCredits . "\n";
}
?>
|
Buy Credits |
Buys more credits for your account. You may purchase credits using a credit card you have stored in your Ez Texting account, or you may pass credit card details when you call the API. |
Code Samples - Stored Card |
|
PHP - XML
<?php
$data = array(
'User' => 'winnie',
'Password' => 'the-pooh',
'NumberOfCredits' => '1000',
'CouponCode' => 'honey2011',
'StoredCreditCard' => '1111'
);
$curl = curl_init('https://app.eztexting.com/billing/credits?format=xml');
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// If you experience SSL issues, perhaps due to an outdated SSL cert
// on your own server, try uncommenting the line below
// curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
curl_close($curl);
$xml = new SimpleXMLElement($response);
if ( 'Failure' == $xml->Status ) {
$errors = array();
foreach( $xml->Errors->children() as $error ) {
$errors[] = (string) $error;
}
echo 'Status: ' . $xml->Status . "\n" .
'Errors: ' . implode(', ' , $errors) . "\n";
} else {
echo 'Status: ' . $xml->Status . "\n" .
'Credits purchased: ' . $xml->Entry->BoughtCredits . "\n" .
'Amount charged, $: ' . sprintf("%01.2f", $xml->Entry->Amount) . "\n" .
'Discount, $: ' . sprintf("%01.2f", $xml->Entry->Discount) . "\n" .
'Plan credits: ' . $xml->Entry->PlanCredits . "\n" .
'Anytime credits: ' . $xml->Entry->AnytimeCredits . "\n" .
'Total: ' . $xml->Entry->TotalCredits . "\n";
}
?>
|
|
PHP - JSON
<?php
$data = array(
'User' => 'winnie',
'Password' => 'the-pooh',
'NumberOfCredits' => '1000',
'CouponCode' => 'honey2011',
'StoredCreditCard' => '1111'
);
$curl = curl_init('https://app.eztexting.com/billing/credits?format=json');
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// If you experience SSL issues, perhaps due to an outdated SSL cert
// on your own server, try uncommenting the line below
// curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
curl_close($curl);
$json = json_decode($response);
$json = $json->Response;
if ( 'Failure' == $json->Status ) {
$errors = array();
if ( !empty($json->Errors) ) {
$errors = $json->Errors;
}
echo 'Status: ' . $json->Status . "\n" .
'Errors: ' . implode(', ' , $errors) . "\n";
} else {
echo 'Status: ' . $json->Status . "\n" .
'Credits purchased: ' . $json->Entry->BoughtCredits . "\n" .
'Amount charged, $: ' . sprintf("%01.2f", $json->Entry->Amount) . "\n" .
'Discount, $: ' . sprintf("%01.2f", $json->Entry->Discount) . "\n" .
'Plan credits: ' . $json->Entry->PlanCredits . "\n" .
'Anytime credits: ' . $json->Entry->AnytimeCredits . "\n" .
'Total: ' . $json->Entry->TotalCredits . "\n";
}
?>
|
Code Samples - Non-Stored Card |
|
PHP - XML
<?php
$data = array(
'User' => 'winnie',
'Password' => 'the-pooh',
'NumberOfCredits' => '1000',
'CouponCode' => 'honey2011',
'FirstName' => 'Winnie',
'LastName' => 'The Pooh',
'Street' => 'Hollow tree, under the name of Mr. Sanders',
'City' => 'Hundred Acre Woods',
'State' => 'New York',
'Zip' => '12345',
'Country' => 'US',
'CreditCardTypeID' => 'Visa',
'Number' => '4111111111111111',
'SecurityCode' => '123',
'ExpirationMonth' => '10',
'ExpirationYear' => '2017'
);
$curl = curl_init('https://app.eztexting.com/billing/credits?format=xml');
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// If you experience SSL issues, perhaps due to an outdated SSL cert
// on your own server, try uncommenting the line below
// curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
curl_close($curl);
$xml = new SimpleXMLElement($response);
if ( 'Failure' == $xml->Status ) {
$errors = array();
foreach( $xml->Errors->children() as $error ) {
$errors[] = (string) $error;
}
echo 'Status: ' . $xml->Status . "\n" .
'Errors: ' . implode(', ' , $errors) . "\n";
} else {
echo 'Status: ' . $xml->Status . "\n" .
'Credits purchased: ' . $xml->Entry->BoughtCredits . "\n" .
'Amount charged, $: ' . sprintf("%01.2f", $xml->Entry->Amount) . "\n" .
'Discount, $: ' . sprintf("%01.2f", $xml->Entry->Discount) . "\n" .
'Plan credits: ' . $xml->Entry->PlanCredits . "\n" .
'Anytime credits: ' . $xml->Entry->AnytimeCredits . "\n" .
'Total: ' . $xml->Entry->TotalCredits . "\n";
}
?>
|
|
PHP - JSON
<?php
$data = array(
'User' => 'winnie',
'Password' => 'the-pooh',
'NumberOfCredits' => '1000',
'CouponCode' => 'honey2011',
'FirstName' => 'Winnie',
'LastName' => 'The Pooh',
'Street' => 'Hollow tree, under the name of Mr. Sanders',
'City' => 'Hundred Acre Woods',
'State' => 'New York',
'Zip' => '12345',
'Country' => 'US',
'CreditCardTypeID' => 'Visa',
'Number' => '4111111111111111',
'SecurityCode' => '123',
'ExpirationMonth' => '10',
'ExpirationYear' => '2017'
);
$curl = curl_init('https://app.eztexting.com/billing/credits?format=json');
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// If you experience SSL issues, perhaps due to an outdated SSL cert
// on your own server, try uncommenting the line below
// curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
curl_close($curl);
$json = json_decode($response);
$json = $json->Response;
if ( 'Failure' == $json->Status ) {
$errors = array();
if ( !empty($json->Errors) ) {
$errors = $json->Errors;
}
echo 'Status: ' . $json->Status . "\n" .
'Errors: ' . implode(', ' , $errors) . "\n";
} else {
echo 'Status: ' . $json->Status . "\n" .
'Credits purchased: ' . $json->Entry->BoughtCredits . "\n" .
'Amount charged, $: ' . sprintf("%01.2f", $json->Entry->Amount) . "\n" .
'Discount, $: ' . sprintf("%01.2f", $json->Entry->Discount) . "\n" .
'Plan credits: ' . $json->Entry->PlanCredits . "\n" .
'Anytime credits: ' . $json->Entry->AnytimeCredits . "\n" .
'Total: ' . $json->Entry->TotalCredits . "\n";
}
?>
|
Carrier Lookup |
| Returns the wireless carrier of a valid mobile phone number (US & Canada) |
Code Samples |
|
PHP - XML
<?php
$data = array(
'User' => 'winnie',
'Password' => 'the-pooh'
);
$curl = curl_init('https://app.eztexting.com/sending/phone-numbers/2345678910?format=xml&' . http_build_query($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// If you experience SSL issues, perhaps due to an outdated SSL cert
// on your own server, try uncommenting the line below
// curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
curl_close($curl);
$xml = new SimpleXMLElement($response);
if ( 'Failure' == $xml->Status ) {
$errors = array();
foreach( $xml->Errors->children() as $error ) {
$errors[] = (string) $error;
}
echo 'Status: ' . $xml->Status . "\n" .
'Errors: ' . implode(', ' , $errors) . "\n";
} else {
echo 'Status: ' . $xml->Status . "\n" .
'Phone number: ' . $xml->Entry->PhoneNumber . "\n" .
'CarrierName: ' . $xml->Entry->CarrierName . "\n";
}
?>
|
|
PHP - JSON
<?php
$data = array(
'User' => 'winnie',
'Password' => 'the-pooh'
);
$curl = curl_init('https://app.eztexting.com/sending/phone-numbers/2345678910?format=json&' . http_build_query($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
// If you experience SSL issues, perhaps due to an outdated SSL cert
// on your own server, try uncommenting the line below
// curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
curl_close($curl);
$json = json_decode($response);
$json = $json->Response;
if ( 'Failure' == $json->Status ) {
$errors = array();
if ( !empty($json->Errors) ) {
$errors = $json->Errors;
}
echo 'Status: ' . $json->Status . "\n" .
'Errors: ' . implode(', ' , $errors) . "\n";
} else {
echo 'Status: ' . $json->Status . "\n" .
'Phone number: ' . $json->Entry->PhoneNumber . "\n" .
'CarrierName: ' . $json->Entry->CarrierName . "\n";
}
?>
|