Reputation: 57
I am trying to use for my own Website this Script https://github.com/briancray/PHP-URL-Shortener. On the Readme it tells this here
To programmatically shorten URLs with PHP use the following code:
$shortenedurl = file_get_contents('http://yourdomain.com/shorten.php?longurl=' . urlencode('http://' . $_SERVER['HTTP_HOST'] . '/' . $_SERVER['REQUEST_URI']));
If i add this Code to any Page of my Website it should shorten the actually Sites Link. But it will not show me the Link and Shorten it.
Upvotes: 1
Views: 138
Reputation: 5440
Doing
$shortenedurl = file_get_contents('http://yourdomain.com/shorten.php?longurl=' . urlencode('http://' . $_SERVER['HTTP_HOST'] . '/' . $_SERVER['REQUEST_URI']));
would only shorten it and save it as a variable. To display it, you will need to display the contents of the variable using echo
. Try this:
$shortenedurl = file_get_contents('http://yourdomain.com/shorten.php?longurl=' . urlencode('http://' . $_SERVER['HTTP_HOST'] . '/' . $_SERVER['REQUEST_URI']));
echo $shortenedurl;
Upvotes: 1