◄ Older Entries | RSS

Receiving and Sending Text Messages With PHP and IMAP

0


I've had a lot of requests to turn some of my Twitter apps into mobile services. Most companies, like Twitter itself, use Short Codes (like 40404) to accept and send txt/sms messages. Short codes are very expensive (the cheapest solution I found started at $500 per month for a randomized short code of up to 8 digits). I knew there had to be a "poor man's" way around buying a short code so I made one using PHP and IMAP.

I've only had around 200 people use it thus far but it seems to be working nicely. It's rough and can use a lot more work, but that's up to you.
You need to setup an email address for mobile users to send their messages to (I suggest m@yourdomain.com for simplicity).

 
<?php
$mail=@imap_open("HOST","USERNAME","PASSWORD") or die("Can't connect: " . imap_last_error());
 
$mails=imap_num_msg($mail);
if($mails==0) { die('No new texts.'); } else {
	echo "There are $mails new texts";
	for($i=1;$i<=$mails;$i++) {
		$chead=imap_headerinfo($mail,$i);
		$mid=ltrim($chead->Msgno);
		/* Attempt to remove some of the garb headers and such that
		some providers and phones send with messages */
		$tweet = substr(imap_body($mail,$mid), 0, 144);
		list($tweet, $trash) = split('[=]', $tweet);
		list($tweet, $trash) = split('Sent from', $tweet);
 
		//Now that we have the message from the user's phone, send out a return message.
		$from1 = $chead->from; //1 due to the probability of having a $from var already defined in your script.
		foreach ($from1 as $id => $object) {
			$toaddress = $object->mailbox . "@" . $object->host;
		}
 
		//Send the text message
		echo "Message Received: $tweet  Send to $toaddress";
		mail("$toaddress", "Your message receipt!", "Your tweet has been received.");
		echo "
<hr />";
	}
}
 
imap_close($mail);
?>
 

The only hitch is that some phones don't allow users to input symbols, or sometimes even letteres, into the to box for a text message. There's a way around that, too (if your users only think to do it). They simply need to add your email address as a contact prior to creating the message. It's the matter of simply selecting a contact to send the message to, then.

Another way around this is to send the message to the provider's SMS email gateway (I don't know all, but AT&T's is 36245). Then, in the body of the message, type "m@yourdomain.com MESSAGE HERE". The provider will automatically strip the email address from the start of the txt and send the message, minus the email address at the beginning, to said email address.

It's the long way around and I'm sure there is a simpler solution. This is my solution and it works fine for what I need it to do.

Read More


A design in the works

0


Just to keep my blog semi updated (seems I'm just letting this place collect dust), here's what I'm working on for today.

This design won't be used. I liked where it was going, the client didn't. Figured I'd share it before I toss it.

Also, I'm working on something new for this blog. It needs to be used more and it needs a better look.

Read More


An Update on the House

1


After a week or so of very hard work, we decided trying to clean everything up and restore the house was a futile attempt. Everything we really wanted to save/couldn't afford to replace immediately was cleaned up, boxed, and stored at my brother's house. After a couple weeks of cleaning and boxing, the house was empty, dirty, and full of stuff that used to be valued possessions now covered in mud, scattered throughout the house, all over the floor. It bothered me to see the house I grew up in being abandoned. The yard was a huge mess with mud, sand, and trash that had washed in everywhere.

We called a guy we knew and he came with his dozer and here's the end result:
lot

100_0634

I thought catchin it on video would be something to have (afterall, how many people get to plan to watch their childhood home be destroyed? haha) I quickly grabbed a camera (the only one I could find right off) and sat it on the hood of the truck. I wasn't sure the limit on recording (it was a camera I hadn't used a lot before) so I had to keep checking to see if the card was full/cam was still recording/etc. The video is kinda shaky and the guys who were working were continually walking in front of the cam or standing in front of the cam -- no big deal, though.
YouTube Preview Image

Read More


Push RSS feed to your Twitter feed

1


A friend needed to push/send items from an RSS feed to his Twitter account.

Here's the code in a nice .zip file. Very simple and rough, but it gets the job done nicely. Feel free to add to/modify.
http://kevinsmithdesigns.com/blog/wp-content/uploads/KSDtwitter.zip

Read More


The Vendor Client relationship in real world situations

0


YouTube Preview Image

Read More


More Flood Pictures

4


I've finally had some time to actually look through the pictures and videos I took on the first few days. No video will ever be uploaded, but here are some pictures.


Two days after the flood and it was still much higher than usual


My side yard with one of my buildings pushed against the neighbor's house


Back(ish) yard


What remains of building #1 and misc trash


Building number #1 and backyard


Backyard/fence and ~3 feet of sand/mud


Backyard and uprooted tree


Backyard


Some flowers I had planted just a few days prior. Hadn't even moved them up front yet...


Backyard


Front porch. The water somehow managed to pull the carpet/rug up. It was glued pretty well.


My foot, front sidewalk.


Road in front of the house.


Backyard


Trash out for the National Guard to pick up


Floors are buckling, hooving.


The dryer vent o' mud lol

Read More


Flooded

11


My house was flooded on Friday night/Saturday morning (around 3am). Nothing much else to say so here are some pictures.


More pictures located here: http://hellokevin.com/flood.

Read More


Facebook: Pirate Edition

0


My friend Aken (@cryode, Cryode.com) pointed this out.

Full screenshots:
http://hellokevin.com/files/upload/fb_profile.png
http://hellokevin.com/files/upload/fb_profile2.png

To change yours, scroll to the bottom of Facebook, click English (US) to bring up the language menu, and select "English (Pirate)"

Read More


YouTube Math

3


YouTube Preview Image

"Cute, fuzzy...let's show it to a friend!"

At this moment, that video has just a dash over 8 million views. That's not really any news for a youtube video. Hell, Avril Lavigne's video for "Girlfriend" has over 118 million views (Most Popular YouTube Videos, Alltime).

Back to the kitten video -- I was in my own little world, staring and smiling at the playful lil kittens pouncing around when it hit me: "How many other slobs are blobbing in front of their computers doing the same exact thing?" So, I did some quick math.
8 million views for a video that is roughly 1.5 minutes.
That's 12,000,000 minutes of wasted time. That's 200,000 hours gone. 8,333 days of human life lost. That's 22.8 YEARS of life that can never be lived again. I'm only 21 years old, these cute little kittens, no more than a month or so old, have consumed more human life that I have lived.

Avril Lavgine's crappy video, at 3:48 in length and 118,768,725 views, has consumed a whopping 27,079,269,300 seconds; 451,321,155 minutes ; 7,522,019 hours ; 313,417 days; 858.67 YEARS of life. Someone *please* correct my math if I have made a mistake. This is just hard for me to believe. I had never really stopped to think about how much time is wasted.

Read More


Getting some press

1


My latest project, SecretTweet.com, has been getting noticed by a few major names in the world of news.

LA Times:
http://latimesblogs.latimes.com/jacketcopy/2009/02/like-postsecret.html

New York Times:
http://bits.blogs.nytimes.com/2009/02/27/anonymous-confessions-go-online-with-secrettweet/

And it was on Fox News, too:
YouTube Preview Image

Read More


◄ Older Entries | RSS