Jump to content

Loading messages from Twilio Account to Page


Mckenzo101

Recommended Posts

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 by Mckenzo101
Link to comment
Share on other sites

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 by Mckenzo101
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.