P4P Marketing - SMS Microservice

Documentation


Send

This allows you to send a SMS/MMS. Below are the details.

$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

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 }