Category: API

Learning Swift

Finally my swift skills are coming along. This is a app idea I built over the weekend.  There were a few things that I struggled with (i.e. setting the background color in the navigation bar) but for the most part I think I’m catching on. The idea is basically a demonstration on how to pull TV show listing using Swift and TVMaze’s APIs. I plan to post the source later tonight on GitHub.

TV Show Listing
TV Show Listing Thumbnail

TV Show Summary
TV Show Summary Thumbnail

Date Picker
Date Picker Thumbnail

I have a few more goals that I aiming to cross of my list.

  • How to submit to the App store
  • How to use the push notification feature
  • How to swipe and delete items from a list.

My First Youtube Video

For many years I’ve trolled Youtube, Stackoverflow.com and other sites stock piling information and code on how to do certain things.
So I figured it was time for me to do my part and pay it forward. I decided to so by cranking out some “How To” videos.
This was my first attempt at screen recording and what I found out is that it’s not as easy as it looks.

1st, my audio sucked so I went out and bought some fairly cheap Logitech USB Headsets from Office Depot. btw. Amazon is cheaper but I wanted and needed the headset ASAP.

2nd, Whenever I played back my video it was blurry. So it took me a few takes to figure out that I needed to change the resolutions to 1280×720

3rd, I’ve never used IMovie before so for me something as simple as trimming a clip took hours to figure out. Come to think of it I’ve owned my Mac for like 3 years now and I think this was the first time I’ve opened IMovie on purpose.

Overall it probably took me like 6/8 takes to get to a point where I thought I was done. I’m crossing my fingers hoping that as I do more it will get better.

Soooo my first video is a “How To” video explaining how to download and parse TV listing data using PHP and a very cool API made available by the people over at TVmaze.com.

The site and API’s are free and very easy to use. And like you’ll see from my video you can get something up and running within a few minutes.

So if you find your looking for this type of data, you should definitely see the set of API’s TVmaze.com has to offer.

f.y.i. I have no theme or structured plan in mind for the videos i create. I only plan to do videos on technology I like and use.

getMinified API

After  3 or 4 attempts in building out the getMinified API and its dashboard I think I finally have a finished product.

Everytime I thought things where thought out correctly, I found issues.
Either complexed issues with the code or simple UX issues.

I decided to pared back a bit on the features and  focus primarily on the CSS part.
In the beginning the overall objective was to build out a simple but useful website that I could crank out within a weekend.

…Im about two weeks deep now #sadface

Screenshot of the Sign Up/Sign In dashboard

getMinified API Dashboard Screenshot

Screenshot of the Stylesheet listing dashboards

getMinified API Dashboard CSS view Screenshot

Building GetMinified.com – CSS and JS minifier

So this may be a crazy idea but at the time I thought it was pretty special.
I was working on a project and had to minify some CSS code.
I quickly became exhaust of the whole process.

Edit CSS, minify the code, republish to site. Make more changes to the CSS code, minify the code again , republish the code again.

Depending on how often you make these types of changes this process can get a bit tiresome.
So I thought, Oh crap why not make a API !
The idea was to basically allow developers to work on their code and at anytime save the changes. The API will dynamically return the compress version.

Boom! and thats how GetMinified.com was created.

I bought the domain for less then $5 from Godaddy using a coupon code. Then  the next following day I crushed out the code.

Right now I’m fine tuning the backend but it seems to work as is.
I’m gonna create a API sign up page to collect emails so I’ll be able to notify users if the API updates.

getminified-screenshot

Gmail Contact Importer

Import your Gmail Contacts the fast and easy way (insert Billy Mays voice here)

My overall objective was to build very simple API that would allow a user to download his/her Gmail contacts and display them in a specific format.

In my opinion a API like this should be very popular amongst the social networking sites.

The API has the capability to be configured to show results in several different formats XML, JSON, and PHP format. The PHP format returns the results in an array format.

The operating format is as follows.

  • Source:contacts
  • Gmail:Username
  • Gmail:Password
  • Format:PHP, or XML, or JSON

http://apime.josephtinsley.com/contacts/{user_name}:{user_password}/{format}

http://apime.josephtinsley.com/contacts/bob:I_luv_Tacos/json

A simple way of including the result set into your PHP web page is to use PHP’s file_get_contents function.

1
2
3
4
5
6
7
8
<?PHP

$results = file_get_contents('http://apime.josephtinsley.com/contacts/{Email_Address}:{Password}/{Format}');
print '<pre>';
print_r($results);
print '<pre>';

?>

*results are limited to 25 contacts right now*
Thanks,
Joe

Google’s Analytics API with PHP

I was recently asked about my experience with Google’s Analytics API, my reply was bla, bla, bla, I do not have any experience with their API’s.  But to be honest I couldn’t remember why at that moment I didn’t. I think the only reason was because of their documentation, for some of their API’s it’s a pretty long, difficult read. But overall that wasn’t a very good reason, so I decided to take some time and dive in and whoop that trick (line from the hustle and flow movie).
The goal for this post to help anyone who may be having a hard time understanding how to build a connection to Google’s Analytics API.
So first there are a couple of things you need to know.

There are only two files needed in this script but the connection part is the only part we will be going over, it’s in the gaClass.php file.
So basically I’m still new to  Google’s Analytics API but what I’ve learned so far is that once you’ve established a connection the rest is pretty simple.  So basically that’s why we will be focusing on the establishing a connection part only.

Your first major goal while trying to establish a connection is to collect the authentication string. Within that string is your authentication token, and without that token you can’t get anywhere so remember that. The overall objective is to get the authentication token.

So open up the gaClass.php file and take a look at the construct method, this is where the connection happens. Please contact me if I confuse your somewhere, I try to code so that it’s easy to follow.

  • Within the construct method we start off by collection your email and password that was set on the form page. They of course are needed to connect to your account.
  • We set the url that we will be trying to making a connection to. In this case it’s the ClientLogin URL (https://www.google.com/accounts/ClientLogin) . Take note that the protocol starts with HTTPS.
  • Within our POST request we have a few additional parameters that will need to be pass along including your email and password. A short description of these parameters can be found at (http://code.google.com/apis/analytics/docs/gdata/gdataAuthentication.html) scroll down until you see the HTTP Protocol Details heading
  • Now once we have all the parameters set we will try to actually make the connection. We do this within the next method. The curlConnection method, and it does exactly what it says, tries to makes the connection via cURL
  • The curlConnection method will take the parameters we talked about earlier and send them to the ClientLogin URL via cURL using a POST method. The answer we receive from this post will or will not include our authentication token.
  • Now let’s suppose it does and the header status code equal 200, which means it’s A-OK. Within that connection response output you will see a encrypted string. But look closers you’ll see three variables with three values assigned to it. The variables are labeled , “SID”, “LSID” and  “AUTH”. Well you want the AUTH and it value.  Our next task is to parse out the AUTH variable and its value, and we do this with the setAccessToken method.
  • The setAccessToken is fairly simple we take that string and convert it to an array using PHP’s built in explode function.  The access token should be in the second element. I then assign this value to a token variable to be used later for accessing other parts of the API. If you recall when we started this post the authentication token is essential to other parts of the API. Without it you basically can’t do anything.

So that you can get a idea of what the output data look like.  I’ve included a screen shot of the header response output, the authentication output, when the authentication output is converted into a array, and the authentication token.

Googles Analytics API Header Response

 

 

 

 

 

 

 

 

 

 

 

 

I’m new to Mercurial so please don’t give me a hard time about my commits or the lack of.
https://bitbucket.org/josephtinsley/google-analytics-api/overview

Google Analytics API with PHP

 

 

Reverse IP Look up .V2

I’ve updated my Reverse IP Look up script. This script/tool will attempt to display a list of domain names that are hosted on the same IP address.

My original script was a bit slow, this one should display results a lot  faster. I’ve also add a simple API that can be configure to show results in different formats XML, JSON, and PHP format. The PHP format returns the results in an array format.

The GUI interface is located in the SEO tools section of this site Reverse IP Look up

To access the API, use the URL below.

Just include your domain name where the curly brackets are, then pick a format to display the results in.

Example

http://apime.josephtinsley.com/{domain_name}/php/
http://apime.josephtinsley.com/bk.com/php/

Thanks,

Joseph

== UPDATED APRIL 06, 2011 ==
In the near future I plan to add more API’s
To handle this change you are now required to add the API’s source that you want to use.
The Reverse IP Look Up source is “reverse

So or example
Instead of
http://apime.josephtinsley.com/{domain_name}/php/
It will need to be
http://apime.josephtinsley.com{source}/{domain_name}/php/
so
http://apime.josephtinsley.com/reverse/bk.com/php/
would be the finished URL.

Thanks again,
Joe

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

Twitter IPhone App – Custom API URL

Change of plans. I decided to take an opportunity I came across yesterday.Custom API URL - Twitter IPhone App
Let me explain. I subscribe to Tech Crunch via twitter, that’s my way of keeping up with who’s, who’s and the what’s going on in the tech world. Well I saw a post they made yesterday about a new twitter IPhone application that was coming out or maybe it was just being renamed, I can’t remember but you get the idea, right?  So I thought why not give it a try. So I went to the Itunes App store via my IPhone and  downloaded the app. I played around with it for a while and quickly became very happy with the functionality. It had a butt load of options and was totally ad free. For the longest I had been using Echofon which wasn’t.
Any who, one of the features I played around with while testing was the photo posting. Photo posting is probably one of the most important feature for me. I figure I can text my posts in if needed.

So to test this feature out I added a test twitter account to the app and posted a random photo from my IPhone. The photo showed up immediately which is great, but when I took a closer look I realized it posted the image to Yfrog. WTF, I was kind of irritated for a little while and wonder why in the heck would they use that site, I hate that site. So I went back to the app to see if there where other options I could select from that would allow me to change this out. Echofon has that feature, so I assumed they would also. Now hold your hat on what I’m about to tell you next, it’s a shocker. Not only did they have several options to choose from, they also had an option that would allow you to add your own custom API URL. Yea that’s music to my ears. First off I love using API’s and secondly I just so happen to have a image hosting site that posts to Twitter and Facebook. So that was it, I knew my night was on lock. I took a pause for a few minutes and then went straight to Burger King and grabbed a couple of those $1.00 double cheeseburgers, came back to the house and started coding my ass off. I think I went to sleep around 4 am, but had to get back up by 9:00 am, I had some shares of stock that I was trying to dump before the market bottomed out.

So to make a long story short I completed building the API for my site sometime around 5 p.m. today. It took longer than what I expected because the market went running today. If you’re curious I took home an extra 315 bucks today. But I have everything working now. You can now post images to your Frin.ly account from Twitter’s IPhone app. I’m not advertising the API right now because I want to take sometime to revamp the site before I start to let people use it. I was looking at some of the code and some of it didn’t make since to me, and I was the person who wrote it. Go figure.

Anyway I said all of this to say that I’m off track right now and things will probably be pushed back another week or so I think. But I’ll keep you posted.
Later,
Joe

Geolocation by IP Address with PHP

Something kind of interesting happened today. I was going through my log files and noticed a query for “joe Tinsley woodland park” the query originated from “Medford, Massachusetts”. Woodland Park was an elementary school located on an air force base in South Carolina that I attended when I was a kid. I take it that someone from my past is trying to locate me. That’s pretty cool. The crazy part is I just noticed that I don’t have anyway for anyone to contact me via my website… Ha! I make the craziest moves sometimes.
Well I’ve mentioned all of this to say If you’re looking for a way to pull Geolocation Data from a single IP address try IPpages.com’s APIs. I’ve been using them for some time now and the service is pretty good. It does require some programming knowledge to the extract the data from the XML results.
Please let me know if I can help with any programming questions (PHP only!).

Copyright © 2024 Joseph Tinsley

Theme by Anders NorenUp ↑