MrScabbyUnderpants Posted August 22, 2016 Share Posted August 22, 2016 Hello all, I need some help with a problem I have. I have wrote some software in Java and all is going well - it monitors various sites and their associated shifts. When someone arrives on a site they SMS their site number to a Twilio number I have set up. I'm quite new to programming and this is my first ever application. The application needs to periodically go online and collect any new SMS messages. I need help with this part. I'm going to use Twilio for this, they have all sorts of API's for various languages but because I'm new to all this and know ZIP about RESTful services I need some help please. https://twilio.github.io/twilio-php/ https://www.twilio.com/docs/libraries/php When an SMS is received by Twilio, they make a call to a URL I set up. So if this is php they will make a call to the php script you place on your server, it says in the documentation that this call has all the SMS information with it. So all I want is a simple php script that will collect the information and save it to the end of a txt file on the server. I can then go and collect it periodically by my Java application and parse them into objects for processing and then delete the txt file on the server. I have searched endlessly for a script I can work from as reference but all I seem to find are examples of how to send SMS I need to receive SMS first, can someone bail me out here, I think while all this has been a great experience I really need to finish it off and Im suck at this part of the work? I have tried to read the Twilio docs and help but they are a bit too technical for me at the moment and need some help to get me going! thanks folks, great site. Phil Quote Link to comment https://forums.phpfreaks.com/topic/301969-twilio-and-php-sms-help-please/ Share on other sites More sharing options...
kicken Posted August 23, 2016 Share Posted August 23, 2016 Your callback URL just needs to accept some POST data and store it somewhere. When Twilio calls it they will provide a bunch of details about the SMS as POST fields. You extract the data you want and do whatever you need to do with it. For example: <?php $from = $_POST['From']; $to = $_POST['To']; $message = $_POST['Body']; $handle = fopen('log.csv', 'a'); fputcsv($handle, [$from, $to, $message]); fclose($handle); 1 Quote Link to comment https://forums.phpfreaks.com/topic/301969-twilio-and-php-sms-help-please/#findComment-1536472 Share on other sites More sharing options...
MrScabbyUnderpants Posted August 23, 2016 Author Share Posted August 23, 2016 Thanks, I got it working now, 5 weeks of java code and I hit a brick wall at the server stage! Its all new - good fun but a quagmire of languages and terminology. But Im learning fast - I just needed a push thanks Quote Link to comment https://forums.phpfreaks.com/topic/301969-twilio-and-php-sms-help-please/#findComment-1536478 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.