Mckenzo101 Posted July 1, 2015 Share Posted July 1, 2015 (edited) I'm currently developing an live messaging app that uses Twilio API for text messaging. Twilio (a cloud based company) they host API's for text messaging. I've developed an application that takes txts from a number and displays it on a screen. However on an Admin side of view; I want to be able to DELETE messages (such as inappropriate messages). That's where i'm stuck at. I want to grab all the text messages from my account SID, list them all on one page and selectively delete messages. Could someone provide assistance, I really want to learn as I continue development. Code: <?php // Get the PHP helper library from twilio.com/docs/php/install require_once('/var/www/html/Twilio.php'); // Loads the library // Your Account Sid and Auth Token from twilio.com/user/account $sid = "ACe5fd6c08b5e1f7c8c9688fee68a269c1"; $token = "****"; $client = new Services_Twilio($sid, $token); // Loop over the list of messages and echo a property for each one foreach ($client->account->messages as $message) { print_r($message); echo $message->body; } Edited July 1, 2015 by Mckenzo101 Quote Link to comment https://forums.phpfreaks.com/topic/297142-loading-messages-from-twilio-account-to-page/ Share on other sites More sharing options...
scootstah Posted July 1, 2015 Share Posted July 1, 2015 Did you try their documentation? https://www.twilio.com/docs/api/rest/message Quote Link to comment https://forums.phpfreaks.com/topic/297142-loading-messages-from-twilio-account-to-page/#findComment-1515391 Share on other sites More sharing options...
Mckenzo101 Posted July 1, 2015 Author Share Posted July 1, 2015 (edited) I looked at the the documentation and It seems that I can call on a msg through its SID (as previously stated). However I just want to output at least one msg on a page and have the option to delete it. This is what I've developed so from from the link you've found. <?php // Get the PHP helper library from twilio.com/docs/php/install require_once('/var/www/html/Twilio.php'); // Loads the library // Your Account Sid and Auth Token from twilio.com/user/account $sid = "ACe5fd6c08b5e1f7c8c9688fee68a269c1"; $token = "***"; $client = new Services_Twilio($sid, $token); // Get an object from its sid. If you do not have a sid, // check out the list resource examples on this page $sms = $client->account->sms_messages->get("SM800f449d0399ed014aae2bcc0cc2f2ec"); echo $sms->body; print "Message Control Pannel"; print "<br>"; print $sms; ?> Edited July 1, 2015 by Mckenzo101 Quote Link to comment https://forums.phpfreaks.com/topic/297142-loading-messages-from-twilio-account-to-page/#findComment-1515397 Share on other sites More sharing options...
scootstah Posted July 1, 2015 Share Posted July 1, 2015 I'm not sure what the difference between Message and SMSMessage are, but I found a delete method here: https://github.com/twilio/twilio-php/blob/master/Services/Twilio/Rest/Message.php#L63 Quote Link to comment https://forums.phpfreaks.com/topic/297142-loading-messages-from-twilio-account-to-page/#findComment-1515401 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.