phpfail
Regular Member
- Aug 21, 2011
- 236
- 107
Change BITLY USERNAME to your bit.ly username of course, and change the BITLY API KEY to your API key. (Found Here: http://bit.ly/a/your_api_key) then upload to your server in .php format.
Then browse to your server and you will see a form asking for the URL you wish to be generated & the amount to make.
You need to have a ? at the end of the URL, E.g. http://site.com/? or http://site.com/file.php? as the generator will make links like site.com/?24824242. If your URL already has a ? in it put an & on the end, E.g. site.com/?p=22&
Leave a post if this helped you! I want to make sure someone gets some use out of it!
Then browse to your server and you will see a form asking for the URL you wish to be generated & the amount to make.
You need to have a ? at the end of the URL, E.g. http://site.com/? or http://site.com/file.php? as the generator will make links like site.com/?24824242. If your URL already has a ? in it put an & on the end, E.g. site.com/?p=22&
PHP:
<?php
function make_bitly_url($url){
$format = 'xml';
$version = '2.0.1';
$bitly_login = 'BITLY USERNAME';
$bitly_api = 'BITLY API KEY';
$bitly = 'http://api.bit.ly/shorten?version='.$version.'&longUrl='.urlencode($url).'&login='.$bitly_login.'&apiKey='.$bitly_api.'&format='.$format;
$response = file_get_contents($bitly);
if(strtolower($format) == 'json'){
$json = @json_decode($response,true);
return $json['results'][$url]['shortUrl'];
}else{
$xml = simplexml_load_string($response);
return 'http://bit.ly/'.$xml->results->nodeKeyVal->hash;
}
}
if (isset($_POST['doit'])&&($_POST['doit']==1)){
$tocreate = $_POST['tocreate'];
$url = $_POST['url'];
echo "<textarea cols='30' rows='30'>";
for ($i=0;$i<$tocreate;$i++){
$url = $url.rand(0,9999999);
$link = make_bitly_url($url);
echo $link."\r\n";
}
echo "</textarea><br /><br />";
echo "<a href=''>Create More Links</a>";
exit;
}
echo "<form action='' method='post'><input type='hidden' name='doit' value='1' />";
echo "URL: <input type='text' name='url' size='100' value='' /><br /><br />";
echo "Create X Bit.ly's Of The Above URL: <input type='text' size='1' name='tocreate' value='100' /><br /><br />";
echo "<input type='submit' value='Create Links' />";
echo "</form><br /><br />";
echo "(Remember To Include A ? At The End Of The URL Or A & If The URL Already Uses A ?)";
?>
Leave a post if this helped you! I want to make sure someone gets some use out of it!