OK, I am confused. First, I am writing in PHP. I am not even handling
signups right now, I am trying to make this work with a single number
I have signed up. So far, I can send a message from the phone, it's
received properly and the proper message is sent back and then a
second message is sent to the mobile complaining about the text/html
problem. I have read a lot of comments in the group about this and
read all the sample code. It's left me confused. I have a function
that sends the response to Zeep: See below
<?function sendsms($number , $message)
{
define( API_URL, '
https://api.zeepmobile.com/messaging/2008-07-14/
send_message' );
define( API_KEY, 'mykeyhere' );
define( SECRET_ACCESS_KEY, 'myaccesskeyhere' );
$http_date = gmdate( DATE_RFC822 );
$parameters = "user_id=" . rawurlencode($number) .
"&body=".rawurlencode($message); //version with urlencoded id per
http://aboutdev.wordpress.com/2009/02/09/zeep-mobile-sms-with-ads/
$canonical_string = API_KEY . $http_date . $parameters;
$b64_mac = base64_encode(hash_hmac("sha1",
$canonical_string,SECRET_ACCESS_KEY, TRUE));
$authentication = "Zeep " . API_KEY . ":$b64_mac";
$header = array(
"Authorization: ".$authentication,
"Date: ".$http_date,
"Content-Type: application/x-www-form-urlencoded",
"Content-Length: " . strval(strlen($parameters))
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, API_URL );
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $parameters );
$response = curl_exec($ch);
curl_close($ch);
return $response;
} ?>
Now in this function there is a header and this is what is required to
send the response to Veep. I tried changing it and things fail. So,
this works. Now, here is the code that calls this function. This is in
an index.php file and is the callback URL so this is what gets called
when people send an SMS.
<?php
include("zeepfunctions.php");
$event = trim($_POST['event']);
switch ($event) {
case 'SUBSCRIPTION_UPDATE':
$userId = $_POST['uid'];
$phoneNumber = $_POST['min'];
break;
case 'MO':
$userId = trim($_POST['uid']);
$msg = $_POST['body'];
$query = "select * from reviewed_thing where thing_description
LIKE '$msg' ";
//dbprocessing here that creates a real and short text message
instead of My Message below
$message = My message";
$result = sendsms($userId , $message);
break;
}
?>
You can see that I'm doing nothing about the subscribe at the moment.
Now, I've read where you have to set a header to content-type: text/
plain using the PHP header() function, but I have no idea where this
should go. Do I build my text message using the headers and add these
headers before my actual text message that gets sent to veep using the
function above? Help!!!
I am so close. This is all working well except that I get a second
text message with the error.
Ted