The Facebook Graph and OAuth 2.0

During my recent Facebook app development using Java, I had to have some minor integration with Facebook, and I am here to share what I have learned and the cool parts about Facebook’s “Graph.”

Introduction to Working with Facebook

When writting my application, it happened to be a canvas app, or it was accessed via apps.facebook.com with a iframe to my acctual app. When I would get a new user I would immediatley get a new cookie that was named fbs_APPID within this cookie, most importantly, there was a access token. Now to know any information about a user, one must have one thing, an OAuth access token.

Getting an OAuth access token

Most times you will have a token in the cookies, however on some random times that I never figured out the pattern to, you just don’t have that information there. And as for most apps, you need to know some information about a user, and possibly even post or something of the like with the users permission. However, for protection, Facebook just doesn’t allow any application developer access to their entire database. So to allow only certain access to certain applications, applications are given OAuth tokens, these tokens are user specificic and generally session specific. With these tokens, you could use the later discussed Facebook Graph to get just about any needed data.
The process of getting an OAuth token if it is not in the “fbs_” cookie can be quite strenuous. First you need to redirect the user to the Graph server with certain application-specific parameters. Next, one of the parameters happened to be a call back url, now that url is called and Facebook gives you a code. Using this code and your application secret you can finally get a new OAuth access token. Basically what all these redirects does is allow Facebook to check that this user is acctually logged in and that this user is allowing the application access to this information.

Read more

Java – The Power Language (for Web or Console)

Recently, I wrote my first Facebook application. It was a small project, and it’s main purpose was to replace the common note entitled something like “Xth grade Schedule!!!” and it was designed to be more efficient for the end user. After inputting your schedule, you would go through and see who is in your classes (that the system already knows). There were other cool features like using some Facebook Social Plugins like the “Like” button and Facebook comments.

Now for this application, as I wrote it in a matter of days and released it the day of schedule releases, I had to go with a language I knew very well, and I had to have a reliable, dependable source to host it at. I automatically though of the Google App Engine as it is pretty sweet to play around with and now would be a great time to test it in a live environment. My previous application I had wrote on Google’s free, scalable engine was written in Python. It utilized the amazing Django framework, but I felt like I didn’t really understand the Python language as well as some others. The only other option for selection on the App Engine was Java. This was perfect as I had just completed a summer class on Java and it was extremely fresh in my mind.

Read more

Social Schedules: My First Facebook Application

I have had this idea for several years, I had always thought the way of sharing schedules on Facebook was inefficient. At my high school I would have to go through 1200 notes, just to see who was in my class.

My application, only available for MHS students, allows you to add your schedule (teachers and classes), see who’s in your class, comment and Facebook Like both your teachers and your hours.

It was written on the Google App engine, using an OO (object oriented) database with JSP’s and Core-servlets. I  will be writing a post about this stuff later.

For some who want to complain about how “bad” it is, I remind you this was about 8 days of work. However here is some of my attached code for it. Note: this is only SOME, not all.

socialschedulesSource [zip]

Java – From a PHP programmers perspective

Java has one heck of a complex “Hello World”, intimidating many away from it. However as I had no choice but to learn it as it was the language of 7/8 weeks of my summer programming class at K-State I had to start using it.

I do not see the “Hello World” that intimidating anymore, for the single reason is that I know what and why all those words are there at the beginning of the file, and the best way for you to get into it is to understand it.

public class HelloWorld {

    public static void main(String[] args) {

        System.out.println("Hello World");

    }

}

The first line is public class HelloWorld. public simply means that from anywhere and by anybody this class can be called. The class simply means that it is a class, as all beginning files in Java will be. The HelloWorld I think should be pretty easy to understand. The second line, public static void main(String[] args)... is a bit more complicated. The public meaning that this method can be called from outside this class. static means that this method can be called without initializing the whole class as an object. void simply means that it returns no value, as methods in the future might, like int or boolean. The next part, main means that this method should be run whenever this program is run, for any Java program to run, there must be a main method. String[] args is probably the strangest part, String is a line of characters, like a word, sentence, anything really. In Java, this [] mean an array, so String[] args means that for it’s parameters it takes an array of Strings. However you won’t deal with this for a while in your Java career. System.out.println... breaks down to System, which is a package (a folder full of classes) and out is a class within the package that deals with output. Finally println is a method (function) which prints the line.

Read more

Ubuntu Tips/Useful things for new Linux people

Reduce all that typing, use the * and ~ command.

As most of you know * is a wildcard, the cool thing is it can be applied virtually anywhere in the Linux Shell. It’s great for being lazy when you don’t want to complete a whole file name.

sudo nano /etc/apache2/sites-enabled/*

That command would edit the sites-enabled file, it is named ( at least on my server ) something strange like “000-default” and instead of remembering that, just put part of it. And a even more known thing is to use a ~ for your home directory, cool thing is you don’t even need to keep it in /home for it to find it.

cd ~/Pictures/May*9

That command would change directory into Pictures in your home directory and go to the folder that starts with May and ends with 9, such as May 2009


Don’t wait for a command to finish, just list them all at once with &&

sudo apt-get update && sudo apt-get upgrade

The command right there is a great command that simplifies Ubuntu updates to just one line, instead of updating ( finding out what needs to be upgraded ) and acctually upgrading the packages. These commands can really be piled on, like yesterday I used the following:

wget http://localhost:8080/ && cat index.html && rm index.html

I would download a file, print it out, and delete it. All in one command. && is great.

sudo mkdir /media/Data && sudo mount /dev/sdc1 /media/Data


Read more

63 Reasons to Love Ubuntu, Linux, and Unix

Intro: Started as 10,20,30 reasons and would add up to 50. There are just too many great things about Ubuntu / Linux / Unix. Look, I sat down to write 50 and Ubuntu ( and Linux ( and Unix )) are so amazing I couldn’t stop until I got to 63 reasons why it is amazing.

11 Reasons to Love Ubuntu:

  • Ubuntuforums.org
  • Simple website, setup, all around simple
  • Apt-get
  • Apt-get
  • Ubuntu Wiki
  • The Ubuntu community
  • Most programs have a special install for it, or at least have specific instructions for Ubuntu.
  • Wonderful built in software
  • 2 Updates a year
  • LTS updates
  • Ubuntu chartroom is great for instant support

Read more

WordPress Update 3.0

I just finished upgrades on the site to 3.0. I have not seen much changes, but it’s always good to be up to date. Just thought I would in form everyone of that.

Just an update

I haven’t posted in a while, so here is an update on what I have been doing:

  • I have installed a gigabit switch and patch panel. It rocks.
  • I have got a server up and running beautifully that my family uses for backups and media streaming
  • I am in the middle of setting up a git server on my server.
  • I have been messing around with RSA and DSA and PGP keys.
  • Finishing up school
  • Prepping for taking CIS 200 at K-State. College class at 15 :D ( Software Design Fundamentals )
  • I have become an avid Ubuntu addict.
  • Can’t wait to get a Macbook.

ObamaCare – Before, During, and After the Fight

What is in this bill?

“We have to pass the bill so that you can find out what is in it.” Speaker of the House, Nancy Pelosi ( D – California )

Now that we have “passed the bill” we can finally “what is in it.” What’s in it? Good question, we have secret deals for Nebraska and other states, we have $500 billion in cuts to Medicare, $52 billion in Social Security cuts, and taking over the loan industry.

Now those first ones are easy to believe, but that last one “taking over the loan industry?” Yes, sadly it is true. According to a March 22 article of USA Today “The government will shut down private lenders, sell expensive loans to 19 million college students and use the profits to finance ObamaCare.”

This bill is loaded with unfair, important-industry-cutting, profiting crap. After just knowing what is in this wretched bill, it should be enough to show you this bill is not right.

Yes, there are some good effects, but it is how we get there. Just like we can quickly solve the middle east problem with a nuke, it’s an unacceptable way of getting there.

How do the American people feel about this bill?

60% disapprove of this bill! And 57% are disgusted at the Democrats way of getting this past, the secret deals, the close door meetings, etc. Since Obama has been pushing this, Obama has hit his lowest rating ever.  These three statistics clearly show most Americans don’t want this, yet Democrats are using crude and rude tactics to get this in. A final, resounding statistic is 11% currently agree with  congress right now. If that doesn’t make something ring in your head, well… nothing will.

Read more

Wiring a gigabit network out of phone lines.

img_3175
img_3166So this morning I got up at 4 a.m. ( yes on a saturday ) and I was ready to go. I have been wanting to get quad-monitors but I had no spots PCI-E or PCI to put in another graphics card. I however had a PCI wireless card that if I could get rid of, I could replace with a dual-headed graphics card.
I was willing to do anything to get a Ethernet line to my room, my dad and I had a plan, it involved going through the unfinished base boards and running Ethernet that way from the heater room. When I was looking for a phone jack to plug the modem into ( for digital telephone, our modem does cable, internet, and telephone all from coaxial ) and I found this wiring that looked like a phone line but it had extra wires. It kept me perplexed for about an hour until I found a website that said most new houses had Cat5E wiring in them for telephone and I knew my house was only about 3 years old so I wondered… I went back and looked at the wire and sure enough it said Cat5E!!

So this is my “make shift gigabit switch and phone switch” as the real 8 gigabit switch and connector pieces are en route. It is connecting my room line and the line to the router as everyone else is yet to get on the bandwagon.

Read more