How to use URL shortener from safeurl.asia with your WordPress site

http://images.pcworld.com/images/article/2012/02/link_clicks_security-11320225.jpg

Now with using Premium URL Shortener, you may want to use it to shorten the URL of your WordPress blog post or page. In this tutorial, I will show you how to achieve that in under 5 minutes.

Things to know before

SafeUrl.asia is Premium URL Shortener with free API.  It allows you to integrate your site with safeurl to shorten the link.  Let’s start!

 Setting up the function

First we will start setting up a function to send the request via the API and to display the result. That function must be added to the functions.php  file of your theme. If you are using a decent WordPress theme, chances are that that file already exists. If not you can simply create one in your theme folder.

Once that file has been created, you must paste the code below in it and add your API key and the site to SAFEURL.ASIA.

function shorten_url($url){

	$siteurl="http://safeurl.asia";
	$apikey="YOUR API KEY"; // You can get it from the user account

	if($apikey && $siteurl){
		$short=@file_get_contents("$siteurl/api?api=$apikey&url=".strip_tags(trim($url)));
		$short=json_decode($url,TRUE);
		if(!$short["error"]){
		 	return $short["short"];
		}
	}
}

Make sure to replace  $apikey by the api key you get from the user panel. An important thing to note about this function is that it does not show the error message. It will only display the short url when it has been successfully shortened. Another thing to note is the name of the function. If you think this name has been taken by a plugin or something else  (which may happen if you use a lot of plugins), then consider changing it to something unique e.g. make_this_url_short($url). Be creative.

Add a shortcode feature

If you are an experienced WordPress user then chances are that you became addicted to shortcodes. These are built in to simplify and to speed writing of content. Registering a shortcode in WordPress is very easy to do. We will use the function above in combination with another simple function to register the shortcode and shorten the URL via the shortcode.

We will again add the following codes in functions.php  of the WordPress theme.

/* This function parses the shortcode content and send it to the main unction */

function shortcode_shorten_url($atts,$content){
   return shorten_url($content);
}

// This code simply registers the shortcode "shorten"
add_shortcode("shorten", "shortcode_shorten_url");

The code above registers the shortcode [ shorten ]THE URL[ /shorten ]. Below is the full code you must add in your theme functions.php.

// Main Function
function shorten_url($url){

	$siteurl="http://safeurl.asia";
	$apikey="YOUR API KEY"; // You can get it from the user account

	if($apikey && $siteurl){
		$short=@file_get_contents("$siteurl/api?api=$apikey&url=".strip_tags(trim($url)));
		$short=json_decode($short,TRUE);
		if(!$short["error"]){
		 	return $short["short"];
		}
	}
}
// Shortcode function
function shortcode_shorten_url($atts,$content){
   return shorten_url($content);
}

// Register Shortcode
add_shortcode("shorten", "shortcode_shorten_url");

To shorten a URL in your post, simply use [ shorten ]THEURL [ /shorten ]. To shorten things like the permalink of the post or page, see the example below.

Shortening Permalinks in your theme files

Now that you set up the function, you can freely use it anywhere you want. All you have to do is to call the main function and provide the URL. If for example you want to shorten the permalink of a post or a page you can use the following code in any part of your template.

<?php echo shorten_url(get_permalink()) ?>

Conclusion

Now that you know how to use this, go ahead and have fun. Leave a comment below to show your appreciation and share this in any way you want.

URL Shortener with free API

Features

Security

We use the most up to date sources available on the internet to block links being created for sites which may contain viruses, spam or malware.

Our script uses some of the most advanced algorithms to keep the user account safe and your phish-free. Passwords are hashed using the phpPass library which is currently one of the best solutions. All URLs go through a series of validation as stated below:

  • URL Format
  • CAPTCHA Check
  • Bot Check
  • Keyword Blacklisting
  • Domain Blacklisting
  • Google Safe Check
  • Phish-Tank Check

QR Code

Each short URL has its own QR that can be accessed by simply adding /qr at the end of the short URL, e.g http://YOUSITE.com/Alias/qr . The QR code in the new version can be dynamically resized by adding a size parameter at the end of the QR code URL, e.g.  http://YOUSITE.com/Alias/qr?size=300×300 . Please note that the maximum allowable size is 550×550.

Custom links

You optimize your ad copy so why not optimize your short links? Educate your audience before they click by customizing the second half of your branded links for higher CTRs.

Get Started

Enterprise Team Management

Manage, control and measure the content being shared across your brand. Segment your analytics by department, location, channel, brand or user.

Get Started

Reporting & Analytics

Better understand your audience. Gain intelligence about your digital efforts and learn what your audience is organically sharing, all in real-time.

Get Started

Workflow Integration

SafeUrl seamlessly integrates into one of the world’s leading social publishing and website content platforms via our world class APIs.

Get Started

Our Clients

Sometimes it’s better to let our clients do the talking.

Get Started

 

Facebook Ads Vs. Google Display Network

The question is often asked is: More good everywhere, Facebook Ads or Google Display Network (GDN)?

The answer is difficult to answer even to this day. Because the factors that determine quite a lot and depending on how we set the campaign in question.

Larry Kim of WordStream create an infographic that explains about this. It should be informed that this data is based on the month of May 2012. Which is also not compared between firms up with Google. But one of their marketing models associated with Display Advertising.

FB vs GOOG
Source from WordStream

Download Files from the Web Directly to your Online Drives

With Save, you can easily upload any file from the Internet directly to your Dropbox, Google Drive or SkyDrive without downloading it the computer.

I have put together a little web app that will let you save files from the web directly to any of your cloud drives be it Dropbox, Google Drive or Windows SkyDrive. There’s no sign-up required, you don’t have to install any extensions and the app works on mobile devices as well.

Save Web Files

Copy Internet files to your account, via the cloud

To get started, put the URL of any web file in the input box, pick a storage service and copy of that file should appear in your cloud drive in no time. You may even put web page URLs in the input box and in that case, the HTML page will get saved to your online drive.

There are a couple of benefits. One, if you are on a mobile phone or a tablet, you can quickly save any file from the Internet to your online drives without using a single byte of 3G data connection as the file transfer will happen via the cloud.

The app can work as a proxy as well allowing you to download files from websites that may otherwise be blocked /inaccessible in your country /workplace. All you need to know is the URL of the file.

Chromebook users may find this even more useful as the SkyDrive or Dropbox clients cannot be installed on these machines.

Google Drive Remote Upload Service

gDrive1 Goodbye Dropbox, Hello Google Drive 

Google Drive Remote Upload

Thoai Media Transfer copies files from servers remotely without having to download them to your PC in the middle. It copies remote files to your google drive directly. It is free completely.

Features:

Easy to use :

  • Starting from putting your url link

Secure

  • We are aware of our clients’ concern for their privacy and for the security of their content. We do everything we can to protect your data:
  • We do not store your content on our servers.
    We do not store your credentials – we rely on the access you provide us via the various cloud services.
  • You can revoke the access at any time.

Efficient