1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Shortened URL Fun!

Discussion in 'Making Money' started by nesterdwarf, Oct 2, 2010.

  1. nesterdwarf

    nesterdwarf Regular Member

    Joined:
    May 30, 2008
    Messages:
    276
    Likes Received:
    539
    Location:
    State of Misery...er, Missouri...
    Following this setup, you'll get two benefits.

    First, this is an easy way to research what your twitter followers are interested in without create any content, at least initially. After you've posted a few (thousand ;)) links, you'll be able to target your efforts towards subjects that you know your followers will respond to.

    Second, and this is the evil part, while figuring out exactly what they want, you can still offer broad advertisements by making the changes to the script outlined below. Basically, we will be creating an iframe of whatever links that we shorten, allowing us to advertise via top/bottom divs, float-in ads, popups, etc.

    Ok, the first thing that you want to do is grab the first .zip file here -

    Code:
    http://code.google.com/p/yourls/downloads/list
    Once you have that, extract the files somewhere that you will remember. Upload all the files to your hosting and follow the installation instructions. When I installed my copy, I had some issues with the redirections that the script tried to run. If that happens to you, just look at the urls that it's trying to send you to and you should be able to sort it all out. Once you have it properly installed, run a few test urls through it and make sure it works.

    So now you have a functional shortener that sends people straight to the destination link... All well and good, and this would let you know what your followers are reading about so you could target those interests. But we want to make some money, right? Changing just a little code and adding a file will let us advertise whatever we want on each of those links.

    First, we'll create the php page with the iframe. Open up your text editor and paste in the following code -

    Code:
    <?php 
    $target = $_GET["forward"]; 
    ?>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    
    <head>
    
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <style type="text/css">
    html, body, div, iframe { margin:0; padding:0; height:100%; }
    iframe { display:block; width:100%; border:none; }
    </style>
    
    </head>
    
    <body>
    
    <iframe src="<?php echo $target ?>" width="100%" height="100%"></iframe>
    
    </body>
    
    </html>
    
    
    Save this file as whatever you want, just remember the name. Upload this file to the root of your YOURLS install and you're done.

    Second, open the folder that you extracted the yourls.zip file to, open the "includes" folder and find the "functions.php" file. Open this in your text editor and find line 729 or search for the text "// Redirect to another page". Within this function, you will see this line of code -

    Code:
    header("Location: $location");
    Change this line of code to read -

    Code:
    header("Location: http://YOURDOMAIN/YOURFILE.php?forward=$location");
    Where YOURDOMAIN would be the domain that you uploaded YOURFILE to ;) Save this file and upload it to the "includes" folder of your YOURLS install. Now all the redirects that you post will open in an iframe on your site. And some sites WILL break out of your iframe, and that's fine. You'll still have the information about your folloers reading the post...

    So now you have a functional shortener that opens in all redirected links in a page on your site...what to do with that?

    Code:
    http://www.webdesignerwall.com/tutorials/jquery-tutorials-for-designers/
    HTH
    ND

    :marchmell
     
  2. matt1972

    matt1972 Regular Member

    Joined:
    Nov 19, 2009
    Messages:
    499
    Likes Received:
    206
    Occupation:
    To make money
    Location:
    192.168.0.1
    Nice, thanks for the post.