Roger Stringer   About ▾

I'm Roger Stringer: a father, writer, developer, consultant, chef, speaker. Founder of TheInterviewr.

Code Archives

How to get a roll call during a Twilio Conference Call


In an ideal world, the start of every conference call would be seamless. Everyone is on the line and everyone knows who is on the call. But, things don’t always work that well. The start of a conference call can leave people talking over each other in an effort to introduce themselves and leave others pretty peeved about the whole process.

Twilio’s conference calling functionality is great in that it is simple to set up, but powerful with just a few tweaks.

In this post, we’re going to set up a moderated conference system with a twist, we’re going to buld a roll call system, so that when a moderator presses the * button, they will redirect to a page which will read back a list of participants, then <Redirect> the moderator back into the conference.

I know, that sounds like a useful feature when you’ve got a scheduled conference call and want to make sure everyone has called in before starting.

So, today, we’re going to show you how to set up a roll call system. To do this, we need a bit of setup.

First, let’s set up the non-moderated caller TwiML when participants call in:

Let’s call this file conference.xml.

Callers who call into this number will be met with a message that the conference will begin when the moderator joins.

Second, we need the TwiML for moderators. So that when a moderator joins, we could append an action on to the <Dial> that would trigger a call to a file which would then announce the end of the conference.

Let’s call this file conferencemod.xml.

Finally, we want to add the code to handle when a moderator presses the * button on their phone.

This will call a file called rollcall.php, which will present the moderator with a list of participants as a roll call, then forward the moderator back into the conference.

Notice, we set the endConferenceOnExit to false? This is because we don’t want to end the conference at this time, we just want the moderator to hear a list of participants, then get forwarded back into the conference. In this case, the conference would end when everyone hung up their calls.

First, we would get a count of particpants still on the conference.

Second, we would cycle through each participant and <Say> that participant’s phone number to the moderator.

Finally, we <Redirect> the moderator back into the <Conference>.

Let’s create rollcall.php:

[This post was originally published on the Twilio blog]

Filed Under: Code


How to rewrite urls with PHP 5.4’s built-in web server


With the release of PHP 5.4, we were given a handy built-in web server. This server is obviously not suitable to use in production environments, but it is great if we want to check on one project quickly:

  • git clone from github
  • composer install to install dependencies
  • run the built-in web server and test the application.
php -S localhost:8888

But it’s also common to use mod_rewrite or similar to send all requests to a master controller. Usually, we’d have a setup like this:

<IfModule mod_rewrite.c>
    Options -MultiViews
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php [QSA,L]

But PHP’s built-in web server doesn’t handle mod_rewrite, and when it came to working on projects, I needed a way to make this work for development. So I came up with this solution of creating one router file and then start the server with it:

And now we start the server with:

php -S localhost:8888 routing.php

All processes are directed through routing.php which then redirects all non-CSS, JS or image requests to index.php and from there the rest is history.

Handy right?

Filed Under: Code


Grab first image in a post and store it as featured image


In cases of older blogs, authors may not have used featured images, but lately, featured images are used more and more as you can use them to handle your blog layout better.

So what do you do on those posts that have no featured image?

This code is a set of functions that I’ve found handy to add to your functions.php.

It will search a post for the first attached image and store it as a featured image. This code also includes functions to check youtube or vimeo if the post has video instead of images:

In your loop.php, or single.php, or anywhere else you use featured images, you would then call it as such:

Filed Under: Code


Detect high-DPI screens in Google Analytics


Marco Arment shared a trick to capture high-DPI screens in Google Analytics over the weekend, but the code he shared is for an older version of Google Analytics, and I wanted to try this out using the newer version of Analytics, so here’s a copy of the code I use here on this site:

Filed Under: Code