4
August 23, 2013

How to fix WordPress to Tumblr video importing

Videos on Tumblr come in all shapes and sizes. Youtube & Metacafe videos are done in iframes, directly uploaded ones in  html5, and then there are all the Javascript players in between. If you’re having issues with the videos importing, it most likely is because of the way WordPress sanitizes the Tumblr posts.

WordPress removes iframes from posts

That’s the main issue. Luckily, there is a solution to disable the WordPress filters while you’re importing.

Below line 411 in tumblr-importer.php, add this line:

kses_remove_filters();

Making your code look like:

do_action( 'tumblr_importing_post', $post );
kses_remove_filters();
$id = wp_insert_post( $post );

And then down on line 434 add this:

kses_init_filters();

Making your code look like:

$this->save_vars();
kses_init_filters();
} while ( false != ($post = next($imported_posts) ) && $this->have_time() );

The kses filters are in place to help prevent malicious code from being imported, and the code above simply disabled them before the import, and then reenabled them once it was completed. Since we probably trust YouTube and the other video sources, we’re allowing the iframes to live inside posts.

You’ll have to do the same modifications if you’re importing drafts. Just add the code to lines 482 and 494 respectively. You can download the importer with my modifications here (make sure you remove the .txt extension).

0
August 2, 2013

Record phone calls, from any device

Record Phone Calls

There have been many times that I wish I had been able to record a phone call. Negotiations, complex customer service requests, the last conversation with my grandpa before he died – all things I wish I could have saved. I’ve searched for iPhone apps to do this, but Apple doesn’t let developers touch and tweak the Phone application.

So I created SecureSpeak.com. It’s a way to record phone calls by doing a 3-way call – you, the person you want to call, and the recording phone line. After you hang up, an mp3 of the recording is emailed to you. Super. Simple.

There are similar apps out there, but all of them require you to know ahead of time that you want to record the call. The way SecureSpeak is designed, you can conference in the recording line at any time during a call, and not have to record 10 minutes of pleasantries before getting to the core of the conversation.

The ones for iOS are mostly VOIP, and depending on your data signal, can lead to some pretty low quality recordings. This system purely uses the phone waves, and leads to higher quality and more reliable calls.

So check out the site and look at how to record phone calls. Starting plans are just $14.99/month, and is worth every penny when you can present concrete evidence in a sticky situation.

4
June 30, 2012

Using Twilio to extend the functionality of Siri

Siri is great for playing music from your iPhone. But if you don’t have the song on your library, Siri can’t go and play it on Spotify, Pandora, Grooveshark, or any of the other players (for now). But if Siri can send a text message to a Twilio number (which I called “Siri Tunes” in my address book), that number can reply with a message linking to an mp3 that can be opened in QuickTime. Watch the demo of the application:

I love building Twilio applications. Contact me if you’re interested having a Twilio application created.

1
June 20, 2011

Mobile Time Tracking using Twilio and Freshbooks

I use Freshbooks to manage all of my invoicing. I manage projects, log hours, and it allows me to keep a careful track of my business. I’m lucky enough to be connect to the internet when I’m working, but for some companies working out in the field, keeping track of hours has been mostly done on pencil and paper.

I built an application integrating Twilio and Freshbooks to solve this problem. Watch the video below to see my Twilio and Freshbooks time tracking system.

How it works

Since you can only submit a completed time log to FreshBooks, the initial clock in call is stored in a database on a separate server. When the user calls back to clock out, it compares the clock out time with the saved clock in time, and then totals up the hours worked. After we know how many hours were worked, the full time log gets submitted to FreshBooks.

Altogether, I mashed up a few different technologies, including:

  • Twilio Voice API
  • Twilio Transcription API
  • FreshBooks API
  • PHP
  • MySQL

If you’re interested in using this for your company, shoot me a message and I’d be happy to set it up for you, or let you license out the code.

1
April 2, 2011

Twilio + WhitePages API = Win

I’m currently working on a Twilio application that requires a complete caller ID lookup system. The caller ID that comes on most phones is very basic, and uses something called CNAM (Caller NAMe). Twilio has a simple CNAM function built in that costs $0.01 per query, but CNAM gives pretty skimpy data. These queries only give one line of info and if the person is using a cellphone, it’s likely only going to give you something like “Wireless Caller” or “Cingular Wireless Customer.”

Thank god for the WhitePages API.

It took me quite awhile to find the API, but when I did I let off a big fist pump. Currently their API is in beta, and only allows you to make 200 calls a day (Pro Tip: build up your own database with all the calls you make to save on repete queries). After a quick whois on whitepages.com, I got their office number in Seattle and next thing I know I’m speaking with Jim Nuccitelli, the director in charge of their API. Jim helped push my application along and told me about some upcoming advances in their API (Spoiler: awesomeness to come).

So, I’ve ripped apart their API and am using it to look up info on incoming numbers through Twilio. Below is a PHP function that does a WhitePages lookup for a ten digit phone number and returns an array with the following:

  • First Name
  • Middle Name
  • Last Name
  • Street Address
  • City
  • State
  • Zip
  • Business Name
  • Phone Type (Cell, home, business, etc)
  • Carrier
function phoneNumberLookup($number){
	// $number should be 10 digits, eg] 4565551337
	$apiKey = "XXXXXXXXXXXXXXX";
	$url = "http://api.whitepages.com/reverse_phone/1.0/?phone=$number;api_key=$apiKey";

	global $whitePages;
	$whitePages = array(
	"wpFirstName" => "",
	"wpMiddleName" => "",
	"wpLastName" => "",
	"wpAddressFullStreet" => "",
	"wpAddressCity" => "",
	"wpAddressState" => "",
	"wpAddressZip" => "",
	"wpBusinessName" => "",
	"wpPhoneType" => "",
	"wpCarrier" => ""
	);

	function contents($parser, $data){
		global $nextVar, $whitePages;
		if( ($nextVar != '') && (trim($data) != '') && ($whitePages[$nextVar] == '') ){
			$whitePages[$nextVar] = $data;
		}
	}

	function startTag($parser, $data){
		global $nextVar;
		switch ($data) {
			case "WP:FIRSTNAME":
				$nextVar = 'wpFirstName';
				break;
			case "WP:MIDDLENAME":
				$nextVar = 'wpMiddleName';
				break;
			case "WP:LASTNAME":
				$nextVar = 'wpLastName';
				break;
			case "WP:FULLSTREET":
				$nextVar = 'wpAddressFullStreet';
				break;
			case "WP:CITY":
				$nextVar = 'wpAddressCity';
				break;
			case "WP:STATE":
				$nextVar = 'wpAddressState';
				break;
			case "WP:ZIP":
				$nextVar = 'wpAddressZip';
				break;
			case "WP:BUSINESSNAME":
				$nextVar = 'wpBusinessName';
				break;
			case "WP:TYPE":
				$nextVar = 'wpPhoneType';
				break;
			case "WP:CARRIER":
				$nextVar = 'wpCarrier';
				break;
		}
	}

	function endTag($parser, $data){
	}

	$xml_parser = xml_parser_create();
	xml_set_element_handler($xml_parser, "startTag", "endTag");
	xml_set_character_data_handler($xml_parser, "contents");

	$fp = fopen($url, "r");
	$data = fread($fp, 80000);

	if(!(xml_parse($xml_parser, $data, feof($fp)))){
		die("Error on line " . xml_get_current_line_number($xml_parser));
	}

	xml_parser_free($xml_parser);
	fclose($fp);

	return $whitePages;

}

Since the WhitePages API requires numbers to be in 10 digit format, I’ve also got a tiny function to sanitize a number for this format.

function phoneFormatTenDigits($number){
	// takes numbers like +14565551337, or (456) 555-1337 and turns them to 4565551337
	$number = preg_replace('[D]', '', $number); // gets rid of all non-digits
	if( substr($number, 0, 1) == '1' ){
		$number = substr($number, 1); // gets rid of the first digit if it's a 1
	}
	return $number;
}

If you used this, say thanks by tweeting out this page.

1
March 20, 2011

Scrub against temporary email addresses

Validating a user’s email addresses is a must, but most developers just pop in the first premade validation function they find without actually evaluating how effective it is.

Most canned functions simply:

  • Check for the @ symbol
  • Check if the domain has a “dot something” at the end

More advanced ones:

  • Check if the domain is actually registered via cURL or PHP functions like dns_get_record and checkdnsrr
  • Check if the TLD exists (against a list of all known ICANN TLDs)
  • Check for existing accounts with the same email, minus periods and pluses (for services like Gmail where bbqsauce@gmail.com, b.b.q.sauce@gmail.com, and bbq.sauce+tastesgood@gmail.com go to the same inbox)

Still, I have never seen a script to filter against disposable email services. Disposable email services allow users to generate a temporary email addresses in a single click. I’ve used mailinator.com over a dozen times to register for a site that I only want to use once. I never have seen a site filter against it.

So here comes Brian to the rescue, giving all you validation junkies a huge list I complied of 119 disposable email domains to check against. If you prefer, you can download this list as a PHP array.

Disposable Email Domains

mailinator.com
thisisnotmyrealemail.com
mailmetrash.com
mytrashmail.com Continue Reading →

3
January 17, 2011

Crack Masterlock Combinations

Master Lock

This past weekend I created a site that makes it easy to retrieve your forgotten Masterlock combination. If you were to manually attempt every combination, you would have to go through 64,000 combinations. This site uses a known masterlock algorithm to bring the possibilities down to just 80. Not bad?

Check it out:

FindCombination.com

So why did you REALLY do this Brian?

I wanted to learn jQuery. I’ve found that it’s easiest to learn something new when you have an end goal in mind. Your brain figures out how to fill in the cracks and actually apply the information you’re taking in. I highly suggest this method of learning. It’s worked well for me with PHP, MySQL, HTML & CSS, SEO, and Affiliate Marketing.