Tag: PHP Code

PHP Sniper, Check the status of Sold Out Product with PHP

New screencast!
So I created a new screencast, a PHP tutorial if you will showing how to use PHP to check the status of sold out products on BestBuy.
I noticed during Black Friday and Cyber Monday there were a few items that appears to be always sold out. So I wrote some code to solve for that.

So if perhaps this code just helps one person grab that hard to purchase item, then I have done my job. 🙂

Thanks america!

Oh by the way the video is titled “Check the status of Sold Out Product with PHP” on YouTube.

How to get a Website Favicon with PHP

New screencast!
Hi all, soooo my new video is not directly related to SEO but I guess it could kind of be if we’re talking about building content.
It’s titled “Get a Website Favicon with Google API #php” I’ve added the #PHP to the end of the title to influence Social Media.

In the video I’m demonstrating how to grab the Favicon from a website using PHP and cUrl.

The Google API I’m using is actually a API I discovered years ago, but surprisingly it still works.

GEO Location data via PHP and IPinfo API

New screencast!
Hi all, so my new video is about getting GEO Location data via the Ipinfo API.
The current title on YouTube is “How to get GEO Location data from IP using PHP and Ipinfo API #php”
This was a pretty simple and straight forward process and of course we used cUrl to get the job done.

But one of the points that I was trying to make is that this data can be used to created highly focus content.

And that sometimes it’s not all about the data that in front of you but more about what the data in front of you can be combined with. Hope that makes sense.

Anyhow thanks!

How to get header response codes using PHP

New screencast!
Okay so I’m happy. This is my 3rd video since my so call comeback.
The video is titled “Get Header Response Code data using PHP” but again I may change out the title within a week to two.
In the screencast we are using the curl_getinfo function in PHP to get the server transfer data. And then carefully (yep I said carefully 🙂 ) parsing through the results to grab the Response code.

Thanks

How to get a websites Title and Meta data using PHP

New screencast available!
I don’t have a set schedule as of yet so I’ve been creating/posting video’s every day.
My latest is titled “Get a websites Title and Meta data using PHP”.
In this video I go over the steps needed to grab a websites Title tag and Meta data using PHP.

PHP has a get_meta_tags functions which makes this task pretty easy. The hard part with this process is grabbing the sites title tag. We went with the preg_match function in order to achieved this.

Using a XML sitemap and PHP to get urls from a competitors website

Sooooo I recently discovered Screencast-O-Matic and now I’m getting back to making YouTube video.

Yep, it’s just that simple. I was previously using Camtasia trial version but could never bring my self around to paying the $199.00.

Screencast-O-Matic is free to use but with limitations (i.e. watermarks, 15 min videos..etc). But the pro version is only $15.00 a year.. geez, can’t beat that.

So my come back video is on SEO and PHP and is currently titled “Get urls from a competitors website using the XML sitemap and PHP.” I mention currently because Im playing around with different version of the title so it may change.

My Youtube channel is listed under name Joseph Tinsley

Thanks! 🙂

Grabbing Stock Market Data using PHP

Using the file_get_contents method is a easy and simple way to grab and parse stock market data using PHP. Yes this is a quick and easy way but for more robust options  like setting custom User Agents and Timeout options you should try utilizing the cUrl function. It’s a lot of material to cover but it’s worth the time.

Make Twitter Updates with PHP and cURL

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);
?>

Fixed Broken Links

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.

Google Favicon API, PHP Code

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);
?>

Copyright © 2024 Joseph Tinsley

Theme by Anders NorenUp ↑