The Data Model and the Set Up

So in this post, I will cover what I did for a data model on the resume part of the site. When I was looking into this part, I was looking to see what I needed, or what needed to happen for this to be effective and capable of doing what I wanted. So I started to look at my own resume, and some of the other sites out there that do this. In any application, it is important to understand exactly what data needs to be captured and why. I think that is where most people usually skimp on, is the why. They think once the data is identified, then that is all they need. but it is not so. One need to understand the “why” of the data in order to properly map and design the DB schema.

Take for example a simple address. It consists of a name it belongs to, number, street name, may or may not contain an apartment/suite number (address line 2), city, state and zip code. Now if we have this information we could maybe say that the name is part of a “Persons” table, and they would be linked to the “Address” table where each field is contained. And normally that may work. But why are you collecting this data in the first place? Is it a basic business application to store customer shipping addresses? Or is it for the city planning, emergency response and police units? Could it be for a post office application, or even political boundary application for a government unit? Each one of these questions may alter the way the data is stored, drastically. For a basic customer database, you could get away with two tables, and in the “Address” table you have one field for address1, address2, and so on. For a city-use application, that may not be normalized enough, and you may have to switch out to three or four tables, and break up address fields into three or more including one field for the number, one for the street name, one for the direction of the street, and one for the type of street. And they may be linked to other tables that contain that data. So just knowing that you have the data identified is not the end. You need to understand the “why”.

So, now we go on to this resume application. And remember, I am building this for me, and only me. I am not building a resume repository so others can create theirs and post it online and via Facebook. This is applicable to me. So I need to find the data that will work for me. I also need to find the data that will work for the people looking to hire people like me. What do they want to see, and why? So after I searched through to see where that would be, I came to the following conclusions. . .
Continue reading The Data Model and the Set Up

Design and Focus for Connecting on Social Media

OK, after the long break I took, I want to refocus on the Resume/personal web application I am building, and how to integrate with Facebook using the Graph API. But before we get into the nuts and bolts of the application, I just want to go over some of the design and focus for this application.

This application is mainly a learning tool, and way to get familiar with the Graph API and keep going with CakePHP. The main user for the administration sections are going to be me. So certain aspects can be adjusted, while others should not. One thing that I can be a little more relaxed on is the input fields. I will allow certain content, but not all. Sanitation of the input data does not need to be paranoid, and I can allow other things to slip through. However, I still want to have security in the back end and allow for checking of proper field id’s and other items that will allow the form to be secure, but give me the flexibility to enter different items in the backend.

Then there is the front end. This will be the forward facing end of the application and will also be the Facebook front. We have added in comments to the application. The next focus is the resume portion. And here is where we can look at the design and focus. By design I mean the design of the application. The UI can be really anything, and I will focus on a simple UI that utilizes HTML5 and CSS3. However, some people I talk to seem to question the aspect of resume portion, as in “why do that when there are countless other sites out there that already allow for this”? That is a good question. And I am not taking anything away from Monster, CareerBuilder, or any other site. LinkedIn provides a way to post your resume as well, and provides a social aspect for it. All of which are great. Remember, firstly, this is a way to experiment and learn more, grow in Graph API and CakePHP. But look at how the world is trending right now in technology.
Continue reading Design and Focus for Connecting on Social Media

A Short Break

As you may have noticed, I have taken a little break from posting. I am having to refocus some of my extra time, what little there is, on some other projects.

However, I will be starting posting again in January of 2011. I will continue the Facebook API integration, CakePHP code and some other things starting the new year.

Make sure to have a good time over the Holiday season, and Merry Christmas to all.

Adding Comments in your Site with the Facebook API

Now that I have jumped almost 2 weeks without a post, as I have been super busy, this should have been a real easy item to post, but I wanted to make sure that this is done correctly. This is probably one of the easiest methods to add some great Facebook functionality in your site. This revolves around comments to a page. In my example, I am posting topics to discuss. This is mainly just a small little blurb that I will enter via an admin form on the site, and then list the different topics for everyone to select one. Once they select it, they can view the details of the topic and then comment on it using the Facebook API/Social plugin. So as always, lets go through a basic plan for this idea.

1. The model is Topic, with a table in the DB labeled “topics”
2. Only the admin has access to add or edit the topics
3. All comments on this topic will be done through the Facebook API/Social Plugin Comments
4. Topics will have a title that will also double as the Unique ID (to be explained later)
5. Topic titles, or themes, will not be allowed to be edited, to be explained why later
6. Administration of the comments will be done by the Facebook Application admins, which differs from the site admins
7. Start Dates will determine if the topic is allowed to be visible yet
8. End dates are optional, and will be built upon later with more advanced FBML/FB JS libraries

And there it is, some basic ideas behind the whole idea. So now lets get into some of the items called out in Numbers 4 and 5
Continue reading Adding Comments in your Site with the Facebook API

Facebook Privacy and Common Sense

This post is just a quick reminder of common sense that should be on every application. Whether it is a Facebook application, a Twitter application, or just a connected application via webservices, you should never expose sensitive data. I mention this because of my previous post which shows how to connect Facebook to a CakePHP application. Even though this is using the basic ideas and examples from the Facebook SDKs, does not mean that this common sense should be disregarded.

An excerpt from a Facebook Developers blog, located at:
http://developers.facebook.com/blog/post/418

Our policy is very clear about protecting user data, ensuring that no one can access private user information without explicit user consent. Further, developers cannot disclose user information to ad networks and data brokers. We take strong measures to enforce this policy, including suspending and disabling applications that violate it.

Recently, it has come to our attention that several applications built on Facebook Platform were passing the User ID (UID), an identifier that we use within our APIs, in a manner that violated this policy. In most cases, developers did not intend to pass this information, but did so because of the technical details of how browsers work.

It is important that when you develop a Facebook application, you adhere to the policies. Remember to take a common sense approach, and make sure you do not violate any security policies.

Facebook Application on the Site

OK, I finally got my data models set up and working. I have the initial CakePHP set up on the site, it is using v1.3, and now I am ready to set it up for the Facebook integration, and start to add the integration. When we first set up the application on the Facebook side, I chose to do an “iframe” version of the application, as I want Facebook on my site, and be able to have integration with some of the great Facebook tools on the site, and be able to “promote me”. And remember this is just a way to show a possible real world example of how to integrate these things with your site. Actual applications may vary, but this is the base to integrate. At least, as of this posting it is the base, it may change in the future.

So lets go ahead and dive into it. If you do not have the application ID for your Facebook application, you can get it at the following:
http://www.facebook.com/developers/apps.php

The next thing is to grab the API and code from Facebook. This can be found at the following page:
http://developers.facebook.com/docs/

This is the main page, and you will need to scroll to the bottom of the page. This will list different APIs that are available. I am going to be using the PHP and JavaScript SDKs. This will provide the back end that I will want, and will also provide a positive user experience on the front end. So be sure to download both SDKs.

After that, now we need to start getting some stuff set up. In this post, I am just going to explain how to get this set up, and working right now. It is important that we get the correct items working, and so we will be working with the “pages” area for the JS SDK, and creating a very simple controller for the PHP SDK so we can get set up and running. I am just using, for right now, the base CakePHP CSS styles and layouts. All we need is a page to display some of the basic items to ensure that we have installed the SDKs in the proper locations. So lets go.
Continue reading Facebook Application on the Site

Its the Simple Things

I am still working forward on the Facebook integration and resume stuff. And will get that posted when I have completed the data model and the basic set up. I will also post about how to integrate Facebook into a CakePHP application. But in the mean time, there was something that happened, that I thought may help me remember.

The other day I was working on an application with a simple login check and display of an error message. I would test the login function with a correct account and an incorrect account. It was driving me batty as when I logged in with wrong credentials, it would not give me the message that something was wrong. I was checking everything. I checked the controller, the model and the view. Could not pin point the issue. I could not find anything wrong. Here is what I had in the view:

if ($sess->check(errors)) {
    $sess->errors);
}

Basically, if the login is incorrect, it will set an error. The session object will read any errors, set the item in the session to display once, and then kill the error so it does not keep happening. And here is the problem, in another application using the same basic code it works fine. Could not pinpoint why this is a problem here. Until I took a brief walk away from the desk. Then I came back and understood what I needed to do.

The check function does not do any displaying of any kind. It is supposed to check the session for errors, and destroy the session element with the errors. Before it does that, it sets a variable for the errors. However, it does not display. I needed to alter it to this:

if ($sess->check(errors)) {
    echo $sess->errors);
}

And there it was! Wow, the littlest thing. I am reminded of a Simpsons episode in which Hank Scorpio tells Homer:
“Well, you can’t argue with the little things. It’s the little things that make up life.”

Indeed it does.

Facebook Integration Initial Steps

The next few posts will examine how I will integrate a Facebook application into one of my sites: stephenhird.com. If you have browsed to this site, you will see there is already a Facebook platform there. And while it does show some of the great things to do with the API, it is very basic and really does nothing. So In this post I will examine what I want to do with it, how to set up an initial application on Facebook, and then go from there. This will likely happen over the next few weeks/months and will be a little more drawn out depending on how much time I have to document this process. This is step one, and step one will always include planning.

First I need to figure out what I want to have on my site. Since it is my name that is on the URL, I will need to create a way that this site will be an online portfolio, biography and information repository. When doing this for any site, it is important to remember your brand. Even for individual sites like this, it is important for branding, because this is who I am, I do not want it to be a classic case of slop on the web. This site before was mainly just a testing ground and now will need to be more.

A side note here, my name is the same spelling as a famous photographer based in London. His site is well put together with good descriptive links and a great example of combining minimalist ideas with styled presentation. He keeps his brand on the pages and the site does not confuse or mislead with extra peripheral items, or overuse of Flash or other heavy web technologies loading down the page. His site is located at: http://www.stephenhird.co.uk/

OK, now on to the planning and setting up the Facebook Application.
Continue reading Facebook Integration Initial Steps

ORM Designs and Tools

ORM, that magical acronym that can send developers into a flurry of excitement, or the rolling eyes of grief. ORM stands for Object Relational Mapping. Used correctly, this can really help applications convert data into objects ready to use. While it does cause some overhead, the key thing to remember is that used properly, it can be really helpful. But that is also the way it is with anything related to code. Since I focus mainly on the open source areas, examining an ORM tool will be limited to the PHP view and aspect.

When designing the data objects, it is important to understand the data and how it relates to the application and other objects. Usually it is the planning sessions that get overlooked, or hurried, and create a problem for later on. This is why using a tool to help with this is always good. I specifically look for more of an ERD (Entity Relationship Diagram) type of tool that can help me visualize and document the data objects. Never underestimate the power of a visual diagram for data. This is worth everything when coming on a new project, or bringing in new resources to a major project. It can drastically decrease the learning curve. There are different tools out there that can help with ERD and ORM design, with the basic Visio diagrams (a Microsoft product), to more robust ERD tools that include different UML (Unified Modeling Language) tools integrated with it like MagicDraw. Each tool will have its pros and cons, no matter what the toolset is, no matter what the project is. I have found that there is not a single tool that is perfect for every project. But finding a good tool that can help in designing the database is a must. If it can even generate code, that is a lot better. One tool that is available that can help with ERD, and generate code, and help with ORM is ORM Designer. And I will examine this tool as it relates to Symfony, CakePHP and non framework applications.
Continue reading ORM Designs and Tools

Facebook Integration

As you have probably noticed, I have integrated a pseudo-Facebook hook into my little WordPress blog. I am wanting more comments to come thru via Facebook, and am building a full Facebook application that will integrate my posts in a non WordPress format, link to different resources on command and provide a way to search and query those items. All on Facebook. The way I am doing this right now is using the Facebook Application with the iframe setting.

So if you have not had a chance to connect to my Facebook App, here is a shameless plug to go ahead and do this now. I will combining the HirdWeb page with the HirdWeb Application. Since I am on Facebook quite a bit, and doing applications for Facebook API integration, I will start to share some of those techniques.

The application I will be walking through is an application I already have half way set up at my own site: www.stephenhird.com. This will soon be taken down and I will be putting up a better site to show the power of the Facebook API and how to integrate your site with Facebook for different things. As always, I will post the entire code page and any connections it needs to have. I will also post the directory structure of a possible integration of the Facebook API into an external application.