Twitter JavaScript API - The Beginning

JavaScript/Ajax, Projects 9 Comments »

I have begun building a javascript API for Twitter which takes advantage of Twitters RESTful web services. So far it only contains the methods to get the user timeline and a user’s profile but will be expanded a lot in the near future. I want to encapsulate every
part of the Twitter API with easy to implement JavaScript / AJAX methods for easily adding Twitter functionality to your websites and applications.

I have setup a simple demonstration to let you see just how easy it can be and the direction I hope to take this API.

This example is very simple and includes the following 2 files (besides obviously the API and a stylesheet).

twitter.html

<html>
<head>
	<title>Twitter JavaScript API</title>
	<script type="text/javascript" src="scripts/twitter.js"></script>
	<link type="text/css" rel="stylesheet" href="scripts/twitter.css"/>
</head>
<body>

	<div><strong>Latest Twitter</strong></div>

	<table>
		<tr>
			<td>

				<div id="twitter">
					<h3>My Twitters</h3>
				</div>

				<div id="speech">
					<img src="images/arr.gif" alt=""/>
				</div>

			</td>
			<td>

				<div id="profile">
					<img id="profile_image" alt=""/>
					<span id="screen_name"></span>
				</div>

				<div id="speech">
					<img src="images/arr2.gif" alt=""/>
				</div>

				<div id="twitter_limit"></div>

			</td>
		</tr>
	</table>

	<script type="text/javascript">
		Twitter.GetUserProfile("justin_");
		Twitter.UserTimeline({user:"justin_",update:"twitter"});
		Twitter.UserTimeline({user:"justin_",update:"twitter_limit",limit:true});
		document.getElementById("profile_image").src = Twitter.UserProfile.ImageUrl;
		document.getElementById("screen_name").innerHTML = Twitter.UserProfile.Name + " says";
	</script>

</body>
</html>

twitter.html makes the API calls which display the results.

twitter.php

<?php

	if(isset($_GET["user_timeline"])) {
		if(isset($_GET["count"])) {
			echo file_get_contents("http://twitter.com/statuses/user_timeline/{$_GET["user_timeline"]}.json?count={$_GET["count"]}");
		}
		else {
			echo file_get_contents("http://twitter.com/statuses/user_timeline/{$_GET["user_timeline"]}.json");
		}
	}

?>

twitter.php does the actual REST request and passes back the resulting JSON code.

As the API grows I will be blogging about it’s progress as well as releasing the code. For now you can access the code throught hte examples but I will have versioned releases and documentation in the near future. Any contribution would be welcomed.

Once this project is firmly established I hope to start a PHP API for Twitter also.

Did you like this post? Be sure to grab my RSS feed so you don't miss out on more great articles.

Classic Programming Joke

Fun No Comments »

Dear Tech Support…

Recently I upgraded from Boyfriend 5.0 to Husband 1.0 and noticed that the new program began making unexpected changes to the flower and jewellery applications that operated flawlessly under Boyfriend 5.0. No mention of this phenomenon was included in the product brochure. In addition, Husband 1.0 uninstalls many other valuable programs such as DinnerDancing 7.5, CruiseShip 2.3, and OperaNight 6.1 and installs new, undesirable programs such as PokerNight 1.3, SaturdayFootball 5.0, Golf 2.4 and ClutterEverywhere 4.5. Conversation 8.0 no longer runs, and invariably crashes the system. Under no circumstances will it run NappyChanging 14.1 or HouseCleaning 2.6. I’ve tried running Nagging 5.3 to fix Husband 1.0, but this all purpose utility is of only limited effectiveness. Can you help?

Sincerely, XXX

Dear XXX:

This is a very common problem women complain about, but it is mostly due to a primary misconception. Many people upgrade from Boyfriend 5.0 to Husband 1.0 with no idea that Boyfriend 5.0 is merely an ENTERTAINMENT package. However, Husband 1.0 is an OPERATING SYSTEM and was designed by its creator to run as few applications as possible. Further, you cannot purge Husband 1.0 and return to Boyfriend 5.0, because Husband 1.0 is not designed to do this. Hidden operating files within your system would cause Boyfriend 5.0 to emulate Husband 1.0, so nothing is gained. It is impossible to uninstall, delete, or purge the program files from the system, once installed. Any new program files can only be installed once per year, as Husband 1.0 has severely limited memory. Error messages are common, and a normal part of Husband 1.0. In desperation to play some of their ‘old time’ favourite applications, or to get new applications to work, some women have tried to install Boyfriend 6.0, or Husband 2.0.

However, these women end up with more problems than encountered with Husband 1.0. Look in your manual under
‘Warnings: Divorce/Child Support.’ You will notice that this program runs very poorly, and comes bundled with HeartBreak 1.3. I recommend you keep Husband 1.0, and just learn the quirks of this strange and illogical system. Having Husband 1.0 installed myself, I might also suggest you read the entire section regarding General Partnership Faults [GPFs]. This is a wonderful feature of Husband 1.0, secretly installed by the parent company as an integral part of the operating system.

Husband 1.0 must assume ALL responsibility for ALL faults and problems, regardless of root cause. To activate this great feature enter the …….

command ‘C:\ I THOUGHT YOU LOVED ME’. Sometimes Tears 6.2 must be run simultaneously while entering the command. Husband 1.0 should then run the applications Apologise 12.3 and Flowers/Chocolates 7.8.

TECH TIP! Avoid excessive use of this feature. Overuse can create additional and more serious GPFs, and ultimately YOU may have to give a’ C:\ I APOLOGIZE ‘ command before the system will return to normal operations. Overuse can also cause Husband 1.0 to default to GrumpySilence 2.5, or worse yet, to Beer 6.0. Beer 6.0 is a very bad program that causes Husband 1.0 to create FatBelly files and SnoringLoudly wave files that are very hard to delete. Save yourself some trouble by following this tech tip! Just remember! The system will run smoothly, and take the blame for all GPFs, but because of this fine feature it can only intermittently run all the applications Boyfriend 5.0 ran. Husband 1.0 is a great program, but it does have limited memory and cannot learn new applications quickly.

Consider buying additional software to improve performance. I personally recommend HotFood 3.0, Lingerie 5.3 and Patience 10.1. Used in conjunction, these utilities can really help keep Husband 1.0 running smoothly. After several years of use, Husband 1.0 will become familiar and you will find many valuable embedded features such as FixBrokenThings 2.1, Snuggling 4.2 and BestFriend 7.6.

A final word of caution! Do NOT, under any circumstances, install Mother-In-Law 1.0.This is not a supported application, and will cause selective shutdown of the operating system. Husband 1.0 will run only Fishing 9.4, Golf6.1 and PubCrawl 5.2 until MotherInLaw 1.0 is uninstalled.

I hope these notes have helped. Thank you for choosing to install Husband 1.0 and we here at Tech Support wish you the best of luck in coming years.

We trust you will learn to fully enjoy this product!

Regards,
IT Specialist

Did you like this post? Be sure to grab my RSS feed so you don't miss out on more great articles.

iPhone Hacked For Carrier Of Your Choice

Hardware, News No Comments »

Yup, it’s true. The iPhone has been hacked by a 17 year old from New Jersey.

Read more…

Did you like this post? Be sure to grab my RSS feed so you don't miss out on more great articles.

Add Google Maps to your .Net site in 10 minutes

ASP.Net No Comments »

Ever wanted to add a Google Map to your site but only had 15 minutes to spare? Now you can add a map and still have time to brag to your mates and bask in the worship that (inevitably) comes afterward.

Basically, the guys over at subgurim.net have already done all the hard work in writing the .Net wrapper for Google Maps. Problem is, the examples on their site are mostly in spanish & its a bit difficult to find out exactly what is needed to get everything working.

Read more…

Did you like this post? Be sure to grab my RSS feed so you don't miss out on more great articles.

Don’t Be a Validation Nazi

Software Design No Comments »

Haacked.com has posted another great article. The basic jist is don’t force your users to input the data as you want but manipulate the data to the way you want it giving your users a much nicer experience. It also has a nice Seinfeld Soup Nazi reference.

Be reasonable; are we so afraid of regular expressions that we can’t strip extraneous characters from a single input field? Let the users type their telephone numbers in whatever they please. We can use a little quick programming to filter out what we don’t need.

Soup Nazi

User: (filling out form) user+nospam@example.com

Validation Nazi: Entering a plus sign is $2.00 extra.

User: But the RFC allows for a plus sign.

Soup Nazi: You want plus sign?

User: Yes please.

Validation Nazi: $3.00!

User: What?

Validation Nazi: No form submission for you!

Did you like this post? Be sure to grab my RSS feed so you don't miss out on more great articles.

AJAX - Amazing Solitaire

JavaScript/Ajax No Comments »

Robert Schultz has created a pretty amazing “ajaxified” version of the classic favorite, Solitaire. Great work Robert, I look farward to possible getting a peek at the code.

solitaire

Did you like this post? Be sure to grab my RSS feed so you don't miss out on more great articles.

PHP Variables

PHP No Comments »

By iain hendry

Variables

A variable is an area of memory which is set aside to store information , this is assigned an identifier by the programmer . You can recognise variables in PHP because they are prefixed with the dollar ( ) sign . To assign a variable you use the assignment operator ( = ) . Here is an example of this.

$name = "shedboy";
$intDaysInWeek = 7;

In the first example the variable identifier in this example is name and the string value “iain hendry” has been assigned to it . In the second example the variable identifier is intDaysInWeek and the number 7 is assigned to it . Note that in the number example we do not surround the variable with quotes in this way PHP treats this as a numeric value but if we had put quotes round it then PHP would have treated it as a string.

Variable Naming

There are some guidelines to follow for naming variables in PHP and these are as follows .
1. All variable names must begin with a letter or underscore character .
2 . The name of the variable can be made up of numbers , letters , underscores but you cant use charcters like , - , & , £ , , etc
One important thing to note if you are coming from another programming language there is no size limit for variables .

Case Sensitivity

One thing that causes many hours of hair pulling and anguish is case sensitivity , PHP is case sensitive (some languages are not) . Here is an example of what I mean.

$myname = "shedboy";
echo $Myname";

Now we all know what we want to do , declare a variable , assign it the value of “shedboy” and then print this on the screen but in this example we have mis-spelt the variable name , when run the following error is displayed on the screen.

Warning: Undefined variable: Myname in D:testsample.php on line 3

Example

Using your favourite HTML editor enter the following

$url = "http://www.geekdaily.net";
$rank = 1;
echo "Our favourite site is ".$url;
echo "“;
echo “It is numbered “.$rank;

If you have enterd this correctly you should get the following displayed

Our favourite site is http://www.geekdaily.net
It is number 1

Did you like this post? Be sure to grab my RSS feed so you don't miss out on more great articles.

Increase Your Traffic by Recovering Your Lost Visitors

SEO/Marketing No Comments »

By Shelley Lowery

If you spend any time surfing the Internet, you’ve probably encountered a few error messages.

Error messages have numerous causes, such as misspellings, outdated links or internal server errors. When an error is encountered, your server will display specific generic error pages according to the error. These error pages are not only dead ends, but they are also very frustrating for your potential visitors.

When your visitors mistype your web address or click on an outdated link and receive the dreaded error page, they’ll most-likely click on their back button and never return. However, you can recover a majority of your lost visitors simply by taking the time to create some customized, user friendly error pages.

As servers run different types of software and do not function in the same manner, there isn’t a simple method for creating custom error pages that will work with every system. However, if you have your own domain and your site is hosted on a Unix/Linux server running Apache, this article will assist you in creating custom error pages.

If you’re not sure what type of server you’re on, visit the following web address to find out:
http://uptime.netcraft.com/up/graph/

Before we begin, keep in mind, editing your server files is serious business. Even one small typographical error can wreak havoc — make sure you make a backup copy of any file you’re planning to edit.

Guidelines for creating your error pages:

1. Create your error pages in standard HTML — just as you would create any other web page for your site.

2. Don’t alarm your visitors. Never include the word “ERROR” in large, bold text. Your visitors may immediately become alarmed and think they’ve done something to cause the error. Instead, be apologetic and encourage your visitors to click on the navigational links to locate additional resources and information.

3. Your error pages should look just like the rest of your web pages. Each error page should contain good navigational links, a search feature, and provide information in regard to the specific error they received.

If you’d like to see an example error page, visit the following web address:
http://www.web-source.net/error.htm

Once you’ve created an error page, save it as the error name. For example, if you’re creating a customized error page for a 400 Bad Request error, your page should be saved as 400.html.

Here are some of the more common errors:

400 Bad Request
401 Authorization Required
403 Forbidden
404 File Not Found
405 Method Not Allowed
500 Internal Server Error
501 Method Not Implemented
502 Bad Gateway
503 Service Temporarily Unavailable

Once you’ve created your pages, you’ll need to access your server via FTP and create a new folder called “errordocs” where you store your HTML files. Upload your new error documents into your new folder.

Your next step will be to locate your .htaccess file and download it to your computer. (If you use FrontPage to publish your web pages, you cannot customize the .htaccess file, as FrontPage uses the .htaccess file. Editing the file may cause errors in your configuration.) The .htaccess file should be located on your server where you store your HTML files.

If the .htaccess file isn’t visible, you can create one within a plain text editor. However, you must first make sure your server isn’t configured to hide the file. Your FTP program should enable you to choose to display hidden files and folders on your server.

Once you’ve downloaded your .htaccess file, open it within a plain text editor, such as Note Pad, and add the following lines below any other text that may be present:

ErrorDocument 400 /errordocs/400.html
ErrorDocument 401 /errordocs/401.html
ErrorDocument 403 /errordocs/403.html
ErrorDocument 404 /errordocs/404.html
ErrorDocument 405 /errordocs/405.html
ErrorDocument 500 /errordocs/500.html
ErrorDocument 501 /errordocs/501.html
ErrorDocument 502 /errordocs/502.html
ErrorDocument 503 /errordocs/503.html

If you’re creating your own .htaccess file, open a plain text editor and add the above lines.

When typing in the information, make certain you type it exactly as it appears above. You can include the error documents of your choice.

Once the file is complete, save it as .htaccess and upload it to your server, via FTP in ASCII mode, where you store your HTML files.

For additional information on File Transfer Protocol (FTP) you may visit:
http://www.web-source.net/ftp_basics.htm

If you have a Windows operating system, you will be unable to save the file as .htaccess. You’ll need to save it as htaccess.txt. Once you upload the file to your server, you can rename it to .htaccess.

That’s all there is to it. When your visitors click on an outdated link, your custom error page will now be displayed.

Creating your own custom error pages is well worth the time and effort, as they will enable you to recover an unlimited number of your visitors. If you follow this step by step guide, you can have your pages up and running in no time.

Copyright © Shelley Lowery

About the Author:

Shelley Lowery is the author of the acclaimed web design course, Web Design Mastery. http://www.webdesignmastery.com And, Ebook Starter - Give Your Ebooks the look and feel of a REAL book. http://www.ebookstarter.com Visit Web-Source.net to sign up for a complimentary subscription to Etips and receive a copy of the acclaimed ebook, “Killer Internet Marketing Strategies.” http://www.web-source.net

Did you like this post? Be sure to grab my RSS feed so you don't miss out on more great articles.

Selecting a Quality Domain Name

SEO/Marketing No Comments »

by Shelley Lowery

When you’re ready to launch your web site and you’re trying to select a good domain name, there are many factors that need to be taken into consideration.

Select a Domain Name that Reflects Your Web Site

Above all else, your domain name should reflect what your web site is all about. For example, if your web site is about grooming a dog, you certainly wouldn’t want to select a domain name like ‘mybusinessname.com,’ as this would have nothing to do with your web site’s focus. You would want to select a domain name that tells the world what your web site is all about — something like ‘doggrooming.com.’

Select a Domain Name that Contains Your Web Site’s Keywords

Another consideration of great importance are your keywords. Try to select a domain name that contains your most relevant keyword phrase, as some Search Engines place relevancy on them. A keyword phrase is two or more words that best describe your web page. If your web page is focusing on grooming a dog, your best keyword phrase will be “dog grooming.”

Select a Domain Name that will be Easily Remembered

With millions of web sites accessible on the Internet, it is also very important to select a domain name that will be easily remembered. As in the ‘doggrooming.com’ example above, ‘doggrooming.com’ is very easily remembered, contains the most relevant keyword phrase and describes the web site in explicit detail. It is the ‘perfect’ domain name for this particular web site.

Select the Best Domain Extension

Another consideration of importance is the domain name extension. Although there are many new domain extensions available, dotcom is still the best choice. When typing in a web address, Internet users automatically want to type in a .com extension, as this is the extension that has been embedded into our brains from the start.

Avoid Using Numbers in Your Domain Name

Although you may be tempted to do so, avoid using numbers within your domain name. Including a number within your domain name can cause problems, as when you tell someone your web address, you will continually have to tell them it’s a number and not the word. For example, if you selected a domain name like number1host.com, if you were to tell someone your web address, they may try to type it as ‘numberonehost.com’ instead of ‘number1host.com.’ This type of domain name would cause confusion.

Avoid using Dashes and Underscores in Your Domain Name

Although many people do it, don’t make the same mistake I made when I first started out. Avoid using dashes, underscores or any other characters within your domain name that may cause confusion. When I registered my domain name, Web-Source.net, I actually wanted websource.com; however, it had already been registered. So, I settled for Web-Source.net. Now, when I tell someone my domain name, I have to say it like this: web dash source dot net.

Don’t get me wrong, www.Web-Source.net is now a high traffic web site, but I can only imagine how much traffic I’ve lost over the years due to my domain name. I have received many emails over the years from visitors who had a hard time finding my site. They said they couldn’t remember the domain name and kept wanting to type in websource.com.

Avoid using Abbreviations within Your Domain Name

Although well-known companies, such as IBM, can get away with using abbreviations within their domain name, most companies can’t. As a rule, try to avoid using abbreviations or anything that will be difficult for your visitors to remember. Not only will this cause confusion, but it can also cause your potential visitors to make spelling mistakes when trying to type in your web address.

Avoid using Long Domain Names

Although you may now register long domain names, it’s really not a good idea. I learned this lesson the hard way. I registered ‘www.workfromhomebusinessguide.com’ and the sad thing is … I can’t remember the domain name half the time. How can I expect my potential visitors to remember it? Try to keep your domain name as short as possible. The longer the domain name the harder it is to remember and the more apt your potential visitors are to make a typo when typing it into their browser.

Ensure Your Domain Name is Not a Trademark Infringement

Prior to registering a domain name, you may want to consider searching the Trademark Electronic Search System, http://www.uspto.gov/main/trademarks.htm to ensure your potential domain name isn’t infringing on any trademarks.

Please don’t take this point lightly, as trademark infringement could cost you your entire business. It is your responsibility to ensure that your potential domain name doesn’t infringe on any registered trademarks, as the trademark laws that apply in the hard copy world also apply on the Internet. Any company that registers a trademark has the right to protect their trademark and has the right to notify you that your domain name is infringing upon their trademark.

When you’re ready to begin, create a list of a dozen or more potential domain names, as chances are, your first choice will already be taken. With any luck, one of the domain names on your list will be available.

Take your time and select a quality domain name that will grow with your business. It will be well-worth your time and effort in the long run.

About the Author:

Shelley Lowery is the author of the acclaimed web design course, Web Design Mastery. http://www.webdesignmastery.com Visit Web-Source.net to sign up for your complimentary subscription to Etips and receive a copy of Shelley’s acclaimed ebooks, “Killer Internet Marketing Strategies” and “Work from Home: A Complete Guide…” http://www.web-source.net

Did you like this post? Be sure to grab my RSS feed so you don't miss out on more great articles.

Does Classic ASP Still Have A Place In A .Net World?

ASP.Net No Comments »

Ever since making the transition from ASP to .Net 3 years ago I haven’t given Classic ASP much thought since. If fact, I have recommend many new developers focus their time on more productive things than bothering to learn ASP.

I was an ASP programmer for 2 years before moving to ASP.Net. I coded 100% in VBScript and that was a major reason I disliked ASP. I am not a VB fan. I know many people like it and that is fine but I like C# much better.

If I did not like VB then why did I use VBScript well, at the time, and still, 99% of examples and code on the net for ASP are in VBScript and it just made things easier then. In the last 3 years though I have fallen in love with JavaScript and it’s insnaley easy way of extending native objects.

I also heard someone not too long ago comment on being able to do the same in ASP/JavaScript. At that time I thought, hmmm, makes sense, why did I think of that before? Although not much became of the idea after.

Today the though crossed my mind again as I was writing some JavaScript code so I decided to give it a go. I threw together this simple example.

<%@ language="javascript"%>
<%
String.prototype.write = function()
{
  Response.Write(this);
}

function Animal()
{
  this.kind = "";
  this.food = "";
  this.eat = function()
  {
    if(this.kind.length < 1)
      "No animal defined!“.write();
    else if(this.food.length < 1)
      "No food defined!“.write();
    else
      (this.kind + “’s like ” + this.food + “. Yum!”).write();
  };
}

var cat = new Animal();
cat.kind = “cat”;
cat.food = “fish”;
cat.eat();
%>

Pretty nice. No VB and some decent OOP happening in ASP. It is however limited to this page but if I were to write a small framework or use something like Dean Edwards base and include it on each page of the project it is a, to me anyways, an exceptable compromise.

I am not going to jump back into ASP but it is certainly fun to play with and with the possibility of a government ASP job looming I am all the more happy to have stumbled upon this.

Cheers

Did you like this post? Be sure to grab my RSS feed so you don't miss out on more great articles.
WP Theme & Icons by N.Design Studio
Entries RSS Login