New CakePHP Twilio Datasource from Aaron Reisman

Cakephp_logoAaron Reisman is a Media Specialist and Founder of Life is Content.
While working on some Twilio projects Aaron
developed a new CakePHP Datasource for accessing the Twilio API via standard model functions. The source code is freely
available on GitHub
. Let’s take a look at an example of how it works.

You’ll need PHP 5.x and CakePHP 1.3.x to use the datasource. Once you have that setup, installation is three easy steps:

  1. Download and add the files to a new CakePHP Project.
  2. Edit the database file and use your credentials.
  3. Modify the texts controller to your needs.

Once configured, a sample controller might look like this:

<?php
class TextsController extends AppController {
function index(){
// Will use the username defined in the $twitter as shown above:
$texts = $this->Text->find('all');
// Create a new text (sends an SMS message)
//$texts = $this->Text->save(array('To' => 4157175170, 'From' => 4152360978, 'Body' => 'This is an update'));
// Finds texts by another username
//$conditions= array('AccountSid' => 'AccountSid');
//$otherTexts = $this->Text->find('all', compact('conditions'));
debug($texts);
}
}
?>

If you use CakePHP, the Twilio Datasource can simplify working with the Twilio API. Head on
over to GitHub
, download it and give it a try in your apps!

Posted by John Sheehan on June 9, 2010
  • Sam

    just tried this out in cakephp 1.3.3. cannot seem to get it to work in sandbox mode. my save statement seems to work correctly, but I cannot tell if the POST is occurring.
    any help would be appreciated. thanks!

  • Sam

    just tried this out in cakephp 1.3.3. cannot seem to get it to work in sandbox mode. my save statement seems to work correctly, but I cannot tell if the POST is occurring.
    any help would be appreciated. thanks!

  • http://profile.typepad.com/twiliojohn John Sheehan

    Hey Sam,
    I’d post this on the forums at http://getsatisfaction.com/twilio where it would probably get more exposure. You can email help as well but the forums will probably be faster.
    John

  • http://profile.typepad.com/twiliojohn John Sheehan

    Hey Sam,
    I’d post this on the forums at http://getsatisfaction.com/twilio where it would probably get more exposure. You can email help as well but the forums will probably be faster.
    John

  • Ravi Bakraniya

    Hi,

    I am getting an error “Fatal error: Class ‘HttpSocket’ not found in D:wampwwwExperimentscakephpappModelDatasourcetwilio_source.php on line 114″.

    I think its because i have not defined any HttpSocket class.

    Please help me.

    Thanks,
    Ravi.

  • Ravi Bakraniya

    Hi,

    I am getting an error “Fatal error: Class ‘HttpSocket’ not found in D:wampwwwExperimentscakephpappModelDatasourcetwilio_source.php on line 114″.

    I think its because i have not defined any HttpSocket class.

    Please help me.

    Thanks,
    Ravi.