troubleshooting Question

Problem with Twilio StatusCallback. Logs show a POST but something is amiss

Avatar of tjyoung
tjyoung asked on
PHPMySQL Server
3 Comments1 Solution1897 ViewsLast Modified:
Hi
I've been trying to see what is wrong for literally hours and still can't figure out why its not working.
I'm hoping if I post my complete code, perhaps someone will see something I've missed:

1) I am receiving a Statuscallback when checking my logs. Here is the latest I've tried (so I see my callback is working/this is direct from my logs):

23.23.3.152 - - [22/Dec/2012:13:16:01 -0400] "POST /app/assets/phone/contests/text_complete.php?contestid=307&account_id=17&callername=NS+Wireless+Call&callercity=HALIFAX&callerstate=NS HTTP/1.1" 200 160 "-" "TwilioProxy/0.7"

2) The total code for text_complete.php code is this:
<?php

	$callsid = $_REQUEST['SmsSid'];
	$callstatus=$_REQUEST['SmsStatus'];
	$to=$_REQUEST['To'];
	$contestid=$_REQUEST['contestid'];
	$account_id=$_REQUEST['account_id'];
	$body = $_REQUEST['Body'];
	$callername=$_REQUEST['callername'];
	$callercity=$_REQUEST['callercity'];
	$callerstate=$_REQUEST['callerstate'];
	$fromcaller=$_REQUEST['From'];	
	
	include '../../db/config.php';
	include '../../db/functions.php';
	

	
//make pretty looking phone number for table display using function
	$fromcallerdisplay = FromCallerDisplay($fromcaller);
	$tocallerdisplay = ToCallerDisplay($to);

//adjust time for incoming calls from timezone using function
$newtime =  GetRightTime($account_id);


$result = mysql_query("SELECT PhoneRate, account_id FROM numbers WHERE PhoneNumber = '$fromcaller' AND PhoneType = 2 LIMIT 1");
while ($row = mysql_fetch_array($result)) {
$phonerate = $row["PhoneRate"];
$account_id = $row["account_id"];
}
mysql_free_result($result);


$sql="INSERT INTO callers (account_id, CallType, CallDirection, ContestId, CallTo, ToCallerDisplay, CallSid, CallerName, CallerCity, CallerState, FromCaller, FromCallerDisplay, Body, CallStatus, CallDate, CallDuration, CallCost, SubscribeStatus)VALUES('$account_id','1','Outgoing','$contestid','$to','$tocallerdisplay','$callsid','$callername','$callercity','$callerstate','$fromcaller','$fromcallerdisplay','$body','$callstatus','$newtime','1','$phonerate','Pending')";
$result=mysql_query($sql);
       	
?>
When I go through the steps in my application, I see no errors in my logs and I see the statuscallback executed in the logs as shown at the top of the page.

If I simply try this url with the bare minimum of a variable attached: http://mydomain.com/app/assets/phone/contests/text_complete.php?account_id=17

The query will work and it will insert into my database the bare minimum. (I was doing this to double-check my query can insert OK). So it seems if even just the account_id is passed, I'll get an insert into my db.

When I plug in the test url above as my statuscallback url with just the required account_id... it doesn't work.

I can see the now shortened statuscallback in my logs show up... but for some reason it won't insert a record.

I simply can't figure out why it isn't inserting a record, even when I do the bare minimum url as my Statuscallback.

Is there some kind of permissions thing perhaps? Where you can visit the url and it will insert, but a callback won't insert?? Just trying to find some new direction to investigate.

Just in case, this is what my StatusCallback code looks like (maybe in case there is something wrong with the way its being formed?)
$subscribestatusmessage = "Hello from $company_name in $city! To subscribe, reply back with the word 'GO' and you are in.";

			/* Include the Twilio PHP library */
			require "../api/Twilio.php";

			/* Set our AccountSid and AuthToken */
			$AccountSid = "mysid";
			$AuthToken = "mytoken";
	
			$client = new Services_Twilio($AccountSid, $AuthToken);
   			
   			$options = array("StatusCallback" => "http://mydomain.com/app/assets/phone/contests/text_complete.php?contestid=".urlencode($contestid)."&account_id=".urlencode($account_id)."&callername=".urlencode($callername)."&callercity=".urlencode($callercity)."&callerstate=".urlencode($callerstate));

   			$sms = $client->account->sms_messages->create(
   			$textcalldisplay,
   			$fromcaller,
   			$subscribestatusmessage,
   			$options
   			);
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros