Latest Blog Entries
Contact Information
Foster Web Designs1.501.690.1981
6056 Allwood Dr.
N. Little Rock, AR 72116
click here to send us a message
Toby's Merrill Site
click here to check out Toby's Merrill site.
Steve Balmer - Developers Developers Developers Developers
As a developer using a alot of Microsoft technologies, I get this stuck in my head quite often... check it out!
Flickr API
my photos, my site, their server
It's getting late so I'm going to get right to it. I started off trying to use PHP to integrate Flickr with my site, but decided I'd rather code in C# tonight. Maybe I'll integrate it all later. My code is below, but is not live. I commented my code inline, if you have questions, feel free to contact me.
Oh yeah, I cheated a bit. I used a toolkit already available - Flickr.NET
protected void Page_Load(object sender, EventArgs e)
{
if (String.IsNullOrEmpty(Request.QueryString["frob"]))
{
//need to authenticate
Flickr f = new Flickr("MyApiKey","SharedSecret");
string url = f.AuthCalcWebUrl(AuthLevel.Read);
Response.Redirect(url);
}
else
{
//frob is the key that is used to get an authToken
string frob = Request.QueryString["frob"];
//authenticate once
Flickr flickr = new Flickr("MyApiKey", "SharedSecret");
//authenticate one more time with authToken in order to use private photos
Auth auth = flickr.AuthGetToken(frob);
Flickr f = new Flickr("MyApiKey", "SharedSecret",auth.Token);
//get photosets using my userid
Photosets psets = f.PhotosetsGetList("MyUserId");
//loop though PhotoSetCollection
foreach (Photoset ps in psets.PhotosetCollection)
{
//display PhotoSet Title and Cover Pic
Response.Write(String.Format("<h3>{0}</h3>", ps.Title));
Response.Write("<img src='" + ps.PhotosetThumbnailUrl + "' /><br />");
//get photos from the current set
PhotoCollection setPhotos = f.PhotosetsGetPhotos(ps.PhotosetId).PhotoCollection;
Response.Write("<div class='setPhotos'>");
//loop through the photos
foreach (Photo p in setPhotos)
{
//display thumbnail with link to popup big picture in a lightbox
Response.Write(String.Format("<a href='{1}' rel='lightbox[{2}]'><img src='{0}' /></a>",p.SquareThumbnailUrl,p.MediumUrl, ps.PhotosetId));
}
Response.Write("</div>");
}
}
}
Day Behind - Flickr API Coming Today
So, I didn't get to play with the Flickr API yesterday. I plan on exploring the Flickr and Google Authentication APIs tonight.
Twitter API
Moe's tweets, my site, their server
After using my del.icio.us rss feed instead of the API (and it being so simple), I decided to do the same with Twitter. And I found out that I'm not the only one, peterelst.com, and it saves some overhead. So I'll get right to it. Here's how I display my tweets...
<?php
//set rss url
$url = "http://twitter.com/statuses/user_timeline/14902000.rss";
//load xml into variable
$rss = simplexml_load_file($url);
//loop through channels (should only be one)
foreach($rss->channel as $channel) {
//loop though items (actual messages)
foreach($channel->item as $item) {
$tweet = str_replace("moeonline: ", "", $item->title);
$tim = str_replace("+0000", "", $item->pubDate);
echo "<div class='tweetWrapper'><div class='tweet'>".$tweet."<div class='pubDate'>".$tim."</div></div></div>";
}
}
?>
see it in action here - Moe's Tweets. I do plan on making a tool to post tweets to Twitter, but for now I'll just login and post them.
Google Maps API
my locations, my site, their maps, their server
For a project I completed sometime in 2007, I needed to display a construction project's location on a map. I used this oppurtunity to use the Google Maps Javascript API. This project would again be a combination of PHP and Javascript.
For some projects I was able to use the address, but most I only had a latitude and longitude. I fully intended to make this project database driven, but after prototyping it I just left the variables hard coded. Below is an example of how I am setting the "project variables".
setup project variables
<?php
$projectId = $_GET['id'];
switch ($projectId) {
case 1:
$projectName = "Lakewood Village";
$projectImgUrl = "images/bigLakewoodVillage.jpg";
$projectAddress = "2851 Lakewood Village Dr, N Little Rock, 72116";
$projectLatLong = "";
$zoom = 17;
break;
case 2:
$projectName = "Burns Park Soccer Fields";
$projectImgUrl = "images/bigBurnsParkSoccer.jpg";
$projectAddress = "";
$projectLatLong = "34.79759408342567,-92.32671976089478";
$zoom = 15;
break;
.
.
.
?>
Now I've got to show a Google Map using these variables. Here's the Javascript that will display the map.
<!--include google maps external javascript-->
<script src="http://maps.google.com/maps?file=api&v=2.x&key=MyApiKey......." type="text/javascript"></script>
<script type="text/javascript">
window.onload=function(){
load(<?php echo "'".$projectAddress."'"; ?>);
}
window.unload=function(){
GUnload();
}
//<![CDATA[
//prepare google map variables
var map = null;
var geocoder = null;
function load(addr) {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map")); //setup map on page
map.addControl(new GSmallMapControl()); //add map controls (zoom...)
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(37.4419, -122.1419), 13); //don't know why this works, but in order to center later, I had to do this.
geocoder = new GClientGeocoder(); //setup geocoder if we are going to use an address
if(addr!="") //if we've setup an address for this location, use it
showAddress(<?php echo "'".$projectAddress."'";?>);
else //otherwise use latitude and longitude
showLatLong();
}
}
function showLatLong() {
//set the center of the map using latitude and longitude php variables as well as the zoom
map.setCenter(new GLatLng(<?php echo $projectLatLong; ?>), <?php echo $zoom; ?>, G_SATELLITE_MAP);
}
function showAddress(address) {
//give the address and let google give us the lat/long
if (geocoder) {
geocoder.getLatLng(
address,
function(point) {
if (!point) {
alert(address + " not found");
} else {
map.setCenter(point, <?php echo $zoom; ?>, G_SATELLITE_MAP); //set the center of the map using the point that google has given us
var marker = new GMarker(point); //put a marker on top of the address on the map
}
}
);
}
}
//]]>
</script>
del.icio.us api (rss feed)
my links, my site, great firefox extension, their server
Let me start by saying that I post all of my bookmarks to del.icio.us using one of my favorite Firefox extensions - del.icio.us Bookmarks. I started to use the del.icio.us api, when I realized that I could use an RSS Feed and parse it with PHP. I find parsing RSS Feeds, or any XML, with PHP to be very very simple. I decided to have a page that shows all of my tags. Once someone clicks on a tag, all of the bookmarks below that correspond to that tag. I am using AJAX (with the help of prototype) to load/reload the bookmarks once a tag is clicked.
code to display all tags
<script type="text/javascript" language="javascript" src="scripts/prototype.js"></script>
<?php
$rss = simplexml_load_file('http://del.icio.us/rss/tags/chuckdfoster/');
foreach($rss->item as $item) {
echo "<a href='linksfromtags.php?tag=" . $item->title . "' onclick=\"new Ajax.Updater('linkholder', 'linksfromtags.php?tag=".$item->title."', {asynchronous:true, evalScripts:true }); return false;\">" . $item->title . "</a>, ";
}
?>
As you can see, each tag is displayed as a link with an onclick="new Ajax.Updater('linkholder', 'linksfromtags.php?tag=.net', {asynchronous:true, evalScripts:true }); return false;". Thanks to Prototype, loading these bookmarks from another page (linksfromtags.php) is easy. Linksfromtags.php will pull all the bookmarks from the tag that is sent in the query string.
code to display bookmarks for a given tag
<?php
$tag = $_GET['tag'];
$url = "http://del.icio.us/rss/chuckdfoster/".$tag;
$rss = simplexml_load_file($url);
foreach($rss->item as $item) {
echo "-<a href='" . $item->link . "'>" . $item->title . "</a><br>";
}
?>
see it in action here - http://www.chuckdfoster.com/mylinks.php.
Five APIs in Five Days
my content, my sites/apps, their server
Starting tomorrow, I plan on exploring five "Web 2.0" APIs in five days. Some are being used for personal reasons, some are being used for freelance projects, and others are being used at Perks.com, my day job, while developing PerksPlus. Here is my schedule...
- Friday - del.icio.us - check it
- Saturday - Google Maps - check it
- Sunday - Twitter - check it
- Monday - Flickr
- Tuesday - Google Auth
I have already used a couple of these APIs (del.icio.us & Google Maps). I have played with one (Google Auth). As for the others, Twitter & Flickr, I don't even have accounts. I plan on using C# or PHP to integrate with some of these APIs from the server-side and using Javascript from the client-side.
One Day Website
It all started with a friend called me and asked me how busy I was. It went from there to me donating my services to a local official, not to mention that they needed the site ASAP. They didn't have much content, but just wanted a "web presence." I started by reviewing some famous politician sites (Obama, Clinton, Rudy) and looking through designmeltdown's collection. I knew I didn't have much time, so I came up with a simple red, white, and blue design. Added his resume. Added a photo of him. Setup the domain at GoDaddy. And boom, it's done. Not the greatest thing I've created, but I don't think it is too bad considering. Not going in my portfolio, but I figured it was blog-worthy.
check out Judge Jim Hamilton's site
First Blog Entry!
So, this blog isn't a "full blog" yet. There isn't RSS, you can't leave comments, and so far I don't even having anything to create my blog entries. But, this is a start.
