Hi,
I want to create a MyCode for URL shortening.
$1 = $url
I need to retrieve the output from the page.
The MyCode that I planned was to be [shorten]http://www.google.com[/spoiler] and the output should be http://j.mp/LmrgCF
Please help me out with this.
Regards,
Mord
This is what I have gotten till now, please guide me further:
I want to create a MyCode for URL shortening.
file_get_contents("http://api.bit.ly/v3/shorten?login=mordalum&apiKey={CENSOREDOUT}&uri={$url}&format=txt");
$1 = $url
I need to retrieve the output from the page.
The MyCode that I planned was to be [shorten]http://www.google.com[/spoiler] and the output should be http://j.mp/LmrgCF
Please help me out with this.
Regards,
Mord
This is what I have gotten till now, please guide me further:
<?php
$plugins->add_hook("parse_message", "shorten_run");
function shorten_info()
{
return array(
"name" => "URL Shortener Script",
"description" => "URL Shortener Script",
"website" => "http://www.seboard.com",
"author" => "Mordalum",
"authorsite" => "http://www.seboard.com",
"version" => "1.0",
"guid" => "",
"compatibility" => "16*"
);
}
function shorten_geturl($input){
$retrieve = file_get_contents("http://api.bit.ly/v3/shorten?login=mordalum&apiKey=R_2734e76af1b52e88f98bcc27cc7a8391&uri={$input}&format=txt");
return $retrieve;
}
function shorten_run($message) {
global $options;
if($options['allow_mycode'])
{
$message = preg_replace("#\[shorten\](.*?)\[/shorten\]#i", "<a href=\'||1\'>||1</a>", $message);
}
return $message;
}
?>