Shahzeb Khan Builds Frank Ocean Album Detection

August 12, 2016
Written by

FO-homepage

Looking for a reason to start playing with Twilio’s PHP Helper Library, Shahzeb Khan built (650)82OCEAN while anxiously awaiting the release of his favorite artist’s latest album.

Boys Don’t Cry is the long suspected second studio release from that of one Frank Ocean. Why a project around Frank Ocean? Shahzeb says, “I mean, it’s become a meme right?”

Fans of the rap artist are all too familiar with the waiting game as the album has been a tease since mid 2013.

Are You There Frank, It’s Me Shahzeb?

Tired of watching Twitter and music blogs so closely for any news of a release, Shahzeb thought he would save time on this effort for himself and two or three friends.

DSC_1850

The Junior at UC Davis is studying Computer Science and Engineering. Putting those skills to use with PHP and Twilio he built (650)82OCEAN as a Lumen application. The project’s namesake comes from the Twilio number (650) 826-2326 behind it.

The service pings iTunes, Spotify, and Twitter every minute or so for any Frank Ocean updates. Inexperienced in the minutia of the album’s history thus far, I jokingly asked, “What if the album drops on Tidal?” Shahzeb laughed, but admitted he had done his research stating that Apple Support has hinted at the release.

The most “complex” part of the application includes a Twilio Controller for Lumen running a background job to handle the sending of SMS. He’s open sourced the following code on Github.

<?php
/**
 * TextController.php: 2 lines to send a text using Twilio (for Laravel and Lumen).
 *
 * By Shahzeb Khan (www.shahzeb.co or @notshahzeb on twitter)
 */

namespace App\Http\Controllers;
use Services_Twilio;
use Log;

class TextController extends Controller
{
	protected $number, $message;

	/**
	 * Create a new TextController instance
	 * @param phone-number $num Phone number for the person being texted
	 */
    public function __construct($num)
    {
    	$this->number = $num;
    }

    /**
     * Send a text message to a given number.
     * @param  text $msg Body for the text message
     * @return bool      ture = text sent, false = error
     */
    public function sendText($msg){
	    $AccountSid = env('TWILIO_SID');
	    $AuthToken = env('TWILIO_AUTH_TOKEN');
	    $client = new Services_Twilio($AccountSid, $AuthToken);
	    $this->message = $msg;
	    
	    try {
	        $message = $client->account->messages->create(array(
	            "From" => "+".env('TWILIO_NUMBER'),
	            "To" => $this->number,
	            "Body" => $this->message,
	        ));
	    } catch (\Services_Twilio_RestException $e) {
	         Log::error("Twilio error while texting ".$this->number.": ".$e->getMessage());
	         return false;
	    }
	    
	    return true;
	    Log::info("Sent text to ".$this->number); ;
	 } 
}

Just A Few Friends

Shahzeb thought about using email at first, but after writing the code in a day he says, “Twilio is actually faster than using email services, which I wasn’t expecting. It’s scaled really well and using it has been an absolute breeze.”

He’s quickly reached 8,500 subscribers for what he likes to think of as the “Frank Ocean Album Detection Service.” It has also been covered

Another thing that took Shahzeb by surprise was having international subscribers. He had people from Brazil and Mexico emailing him to ask if the number would work internationally and subsequently informing him it did indeed work. “Having this international support without any sort of code on my part is awesome,” he said.

When asked if he had any last words for the elusive Ocean, he said, “This code will survive longer than the wait.” This will come in handy if the artist ever decides to release a third album.

Until then, we are indeed waiting and Shahzeb just added another subscriber.

 

complete-signup