Documentation
Send
This allows you to send a SMS/MMS. Below are the details.
- JPG, JPEG, PNG, MP3, OGG, AMR, PDF, MP4 are supported for attachments
- all API calls must be POST
- only one attachment per message is supported
- endpoint is service.p4pmarketing.com/sms/send.php
- all API calls will only pass from IP associated with key
- reference_type, allows for a maximum of 10 chars
- "to/from_phone_number" expects an 11 digit valid phone number in a string format
- optionally you can send an array of "to phone numbers" in the form of 11 digit strings
- "from_phone_number" must be a phone number purchased through P4P
- if you provide a "response_url", replies to that message will get sent to it
- if you provide a "response_text", replies to that message will autmatically be replied to with the provided text
- if you provide a "status_url", the status of your message will be sent to it
- a JSON object that gets returned
- only send an "auth" parameter if you are not using the default P4P account
$to_phone_number = "19055551234";
$from_phone_number = "19055551234";
$message_attachment = "https://upload.wikimedia.org/wikipedia/commons/4/44/Flat-shading-sample.jpg";
$reference_type = "whatever";
$message_body = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
$api_key = "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
$response_url = array("https://www.stuff.com", "https://www.things.com");
$response_text = "Thank you for contacting...";
$auth = array(
$account_sid = "XXXXXXXXXXXXXX";
$auth_token = "XXXXXXXXXXXXXX";
);
$postFields = array(
"to_phone_number" => $to_phone_number,
"from_phone_number" => $from_phone_number,
"message_attachment" => $message_attachment,
"message_body" => $message_body,
"api_key" => $api_key,
"reference_type" => $reference_type,
"response_url" => $response_url,
"response_text" => $response_text,
"status_url" => $status_url
"auth" => $auth
);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://service.p4pmarketing.com/sms/send.php");
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($postFields));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, 1);
$output = curl_exec($curl);
curl_close($curl);
Recieve
- only image file types (png, jpg, gif) can be recieved
This is what gets sent to the "response_url". Below is a sample of the JSON object
{
to_phone_number : 12345678901,
from_phone_number : 12345678901,
original_body : This+should+be+the+original+message.,
body : This is a reply.,
id : SMf3747c7f8a54451c2345a2e7b1234567,
attachment : https://whatever.com/images/SMf3747c7f8a54451c2345a2e7b1234567.jpg
}