| Subcribe via RSS

Make Twitter Updates with PHP and cURL

June 18th, 2010 | No Comments | Posted in API, PHP, Programming

I’m sure I’ve mentioned sometime before that I’m a big fan of Twitter. I think Twitter has done a great job with their API, and the documentation for their API. They’ve made it fairly simple for developers to create Twitter based applications without jumping through a lot of hoops.

Well below is a bit of code I’ve used in the past to make status updates to Twitter. If your familiar with cURL then you’ll see that its pretty straight forward. The end result examines the HTTP code to determine if the status update was successful or failed you can comment this part out if you wish.

But before you go plowing away with the code I think it would be a good idea if you make yourself familiar with their documentation. They have a few rules that could save you some heartache down the road.

== Twitter Documentation ==
http://apiwiki.twitter.com/Twitter-API-Documentation

== PHP Code To Post Twitter Status Updates ==

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?PHP

/* Post Twitter Status Update using PHP & cURL */

function postToTwitter($username,$password,$message){
 
   $username = $username;
   $password = $password;
   $twitterHost = "http://twitter.com/statuses/update.xml";
   $yourStatus = $message;
   $curl;
   
   $curl = curl_init();
   curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 2);
   curl_setopt($curl, CURLOPT_HEADER, false);
   curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
   curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($curl, CURLOPT_USERPWD, "$username:$password");
   curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
   curl_setopt($curl, CURLOPT_POSTFIELDS, "status=". urlencode(stripslashes(urldecode($yourStatus))));
   curl_setopt($curl, CURLOPT_URL, $twitterHost);
   
   $result = curl_exec($curl);
   $resultArray = curl_getinfo($curl);
   
   if ($resultArray['http_code'] == 200) {
   
   $twitterPostStatus = "Success";
   
   } else {
   
   $twitterPostStatus = "Failed";
   
   }
   curl_close($curl);
   
 return $twitterPostStatus;  
}

$username = 'username_here';
$password = 'password_here';
$message = "Working with the Twitter API";

$result = postToTwitter($username,$password,$message);

print_r($result);
?>
Tags: , ,

Fixed Broken Links

June 12th, 2010 | No Comments | Posted in PHP, Programming

I just noticed I had some broken links on my PHP Scripts page. I repaired the links so the downloads should be back to normal.
I have to say I looked over the code that was used to make this scripts and a lot of it is old. I’m leaving it in place hoping that it can still in some way be helpful.
Later,
Joe

- – UPDATED –
I included two scripts that I had on the old site that somehow was forgotten when I made the move.

Tags: , , ,

Google Favicon API, PHP Code

November 10th, 2009 | No Comments | Posted in API, Google, PHP, Programming

I ran into something very, very interesting today. Google Favicon API
(A Favorite Icon API)
. It’s an API that allows you to pull websites Favicons, plus the API dynamically converts the image into a PNG format. This actually comes at a great time because I was just thinking the other day that since I have the option to add offsite URL’s to my site now. Would’nt it would be supa cool if I could also included their Favicon? To beak it down if you look into my site’s right side navigation you will see the “Links” category. Well I thought it would be nice, I mean supa cool if I had a script that could automatically include the corresponding sites Favicons.  And BAM! Thanks Google Favicon API. I wrapped this APIs up with some cURL and a little PHP and now I have a working PHP function. I don’t know much about the Google Favicon API but it looks like it’s been around for about a year. So it’s a good chance that this API could suddenly up and move or disappear all togehter. Basically what I’m saying is I don’t know how long the good times will last. So in my opinion I suggest you consider the use of this script temporary until you can get the time to build a much reliable one yourself.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?PHP
function getFavicon($var){
$filName=substr($var,0,-4);
$fp = fopen ('folder/'.$filName.'.png', 'w+');
$ch = curl_init('http://www.google.com/s2/favicons?domain='.$var);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_exec($ch);
curl_close($ch);
fclose($fp);

}

$var='techcrunch.com';
getFavicon($var);
?>

Tags: , , ,

Display duplicate Keywords from your Title Tag, PHP Code

November 6th, 2009 | No Comments | Posted in PHP, Programming

Display duplicate Keywords from your Title Tag, PHP Code. I whipped this up really quick so please don’t criticize. It’s probably going to be the basis to something much bigger. But I was recently in the need of a script that could flag and report what keywords I had repeated in a list of given title tags.

You all in the SEO business understand that repeating keywords a bunch of times (A.K.A keyword stuffing) is not a tactic that should be practiced.

Feel free to use it and twist it up, but please let me know what you come up with. This would probably be even more valuable if there was some kind of white list feature to take advantage of. I’ll add it if I end up growing this out.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?
function whosUnique($str){
   $parsStr=explode(' ', strtolower($str) );
   $wordArray=array_unique($parsStr);
   $result = array_diff_assoc($parsStr, $wordArray);

return array($str,$parsStr,$wordArray,$result);
}

$str="Briefcases &amp; Totes - Business Tote, Men's Briefcases, Women's Briefcases";

$result = whosUnique($str);

print '<pre>';
print_r($result);
print '</pre>';
?>

Tags: , ,

Joseph Tinsley, WHO.IS

November 5th, 2009 | No Comments | Posted in me

I am currently the Data Feed Manager at a Top Secret Faculty, an Atlanta-based interactive marketing faculty that specializes in Natural and Paid Search Optimization. I’ve been working at this Top Secret Faculty for over 5 years now. As Data Feed Manager, I’m responsible for the technical management of this Top Secret faculty’s Yahoo Search Submit Pro Program and new Beta feed programs.

I’m experienced in server side and client side development, and have developed key analytic applications that have been used to examine search engine trends across multiple verticals.

I’ve earned a Google Adwords Professional Certification and a Yahoo! Search Marketing Ambassador while working at this Top Secret Faculty.
I majored In Management Information Systems and received my Bachelors Degree from Auburn University in 2000.

I enjoy working in the search Marketing Industry but most of all I enjoy building applications that support this industry.

I believe my area of expertise is in identifying and creating solutions that help people become more successful.

Tags: , ,