Created
November 24, 2009 22:08
-
-
Save flukeout/242284 to your computer and use it in GitHub Desktop.
Zeep Mobile - Sending a message
This file contains hidden or 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 | |
// Created by Chris Teft Hughes | |
// Copyright (c) 2009. All rights reserved. | |
// Released under MIT License | |
// ADD TO YOUR CONFIG FILE | |
define('ZEEPSECRECTKEY', 'yoursecret'); | |
define('ZEEPAPIKEY', 'yourapikey'); | |
define('ZEEP_ENDPOINT', 'https://api.zeepmobile.com/messaging/2008-07-14/send_message'); | |
// SEND MESSAGE ZEEP API CODE | |
// LETS SAY YOU GET THE MSG FROM A POST FIELD | |
$messageText = strip_tags(trim($_POST['messageText'])); | |
$httpDate = gmdate('D, d M Y H:i:s \G\M\T'); | |
$postData = 'user_id=' . $yourUsersUniqueID . '&body=' . urlencode($messageTextEncoded); | |
$canonicalString = ZEEPAPIKEY . $httpDate . $postData; | |
$hashSig = base64_encode(hash_hmac('sha1', $canonicalString, ZEEPSECRECTKEY, TRUE)); | |
$headers = array(); | |
$headers[] = "Authorization: Zeep " . ZEEPAPIKEY . ":" . $hashSig; | |
$headers[] = "Date: $httpDate"; | |
$c = curl_init(ZEEP_ENDPOINT); | |
curl_setopt($c, CURLOPT_POST, 1); | |
curl_setopt($c, CURLOPT_HTTPHEADER, $headers); | |
curl_setopt($c, CURLOPT_POSTFIELDS, $postData); | |
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); | |
$result = curl_exec($c); | |
curl_close($c); | |
if($result == 'OK') { | |
// SUCCESS! | |
} else { | |
// FAILED - ECHO TO SEE ERROR | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello Friend,
Can you please tell where I should add the mobile number in this sample.
On the following link
$postData = 'user_id=' . $yourUsersUniqueID . '&body=' . urlencode($messageTextEncoded);
$yourUsersUniqueID = Is this a mobile number?????
If I want to send sms to 1253658662 number where I should add it.