Intergrate Twillio and the Yii Framework

For anyone that wants to integrate the Twillio api with the Yii Framework, here’s a rough guide. Overview: Download the Twilio php api Place the Services folder into your components folder Update your controller Those should be all the steps you need, although I’m looking for a solution to get the code out of the controller and create a Twilio object I can use when I want throughout the application. Comments on how to do that appreciated. Download the Twilio Php API Grab the latest Twilio helper libraries from here: Place the Service folder into your components folder Go /protected/components and place the unpacked Services folder there. You’ll find… Continue reading Intergrate Twillio and the Yii Framework

XML Output with the Yii Framework

My quick solution for getting the Yii Framework to display XML data. I’m just going to give the code from a project that I’m working, so substitute in your own names where necessary. OverviewFiles to create: protected/views/[your_class]/[your_action].php protected/views/layouts/[your_xml_layout].php Files to modify: protected/controllers/[your_controller].php In general, the approach is as follows. Create a layout that wraps our XML and outputs the XML header. Step 1: Create The View FilesFor the layout file, make sure you have at least the bolded text below included: File: protected/views/layouts/[your_xml_layout].php <?php header(“Content-type: text/xml”); ?><?php echo ‘<?xml version=”1.0″ encoding=”UTF-8″?>’?><Response> <Tag><?php echo $content; ?></Tag></Response> I’ll leave it up to you to figure out how you want to wrap your… Continue reading XML Output with the Yii Framework