Mostly practical advices

How to add social bookmarking scripts like “Digg this”?

Social bookmarking websites such as Digg and are great tools to drive traffic to your site and to provide important links (Read more About Social Bookmarks). These services allow varying degrees of automated submissions, and so here you will find the required code to add to your pages to facilitate submission.

Digg bookmark code

Digg does not allow complete automated submission, requiring some human interaction. There are two versions of the code: PHP and Javascript.

PHP Digg script

Using PHP, you can create the “Digg this” link on the server before sending the page to the browser. The code is (all one line):

<a href="<?php echo urlencode("" . $_SERVER["REQUEST_URI"]); ?>”>Digg this</a>
This produces the following link: Digg this.

Javascript “Digg this”

You can use it as a bookmarklet: just drag the link to your bookmark toolbar. A simplified version of the code is:

<a href="javascript:location.href='' + encodeURIComponent(document.location.href) + ' '">Digg this</a>
This produces this link: Digg this. submission code is a very popular social bookmarking service. Its link submission system is similar to Digg’s. Again, we have PHP and Javscript codes. PHP submission code

The PHP code to submit to is:
<a href="<?php echo urlencode("" . $_SERVER["REQUEST_URI"]); ?>&title=<?php echo urlencode($PAGE_TITLE);?>” title=”Post to”>Post page to</a>
This produces this link: Post page to

Note the $PAGE_TITLE variable. This needs to be changed to the page’s actual title. If you are using blog software or a content management system (CMS), you might find that this variable is already present, but called something else. If not, you can submit the page without a title, but this forces the user to type it in. In this case, the code will be:
<a href="<?php echo urlencode("" . $_SERVER["REQUEST_URI"]); ?>” title=”Post to”>Post page to</a>
Which produces this link: Post page to Notice the difference? Javascript submission code

The Javascript code is more straightforward:
<a href="javascript:location.href='' +encodeURIComponent(document.location.href)+'&title=' +encodeURIComponent(document.title)+' '">Post to</a>
Output: Post to

Furl posting code

The Furl submission code is similar to the code above.

Furl PHP code

The code:
<a href="<?php echo urlencode($PAGE_TITLE);?>&u=<?php echo urlencode("" . $_SERVER["REQUEST_URI"]); ?>”>Post page to Furl</a>
Which produces: Post page to Furl

Again, notice the $PAGE_TITLE variable. Unlike using the, if you do not provide a link title, Furl automatically sets it to ‘untitled’. You may want to avoid that.

Furl Javascript code

The code:
<a href="javascript:location.href=''+encodeURIComponent(document.location.href)+'&t='+encodeURIComponent(document.title)+' '">Post to Furl</a>
Which produces: Post to Furl.


Tags: , , , , ,


Posted in JavaScript, PHP. 1,955 views
Responses are currently closed, but you can trackback from your own site.

No Comments

Sorry, the comment form is closed at this time.