I am making an API to shorten links, the links I use could not get the rest of the url after the & sign.
<?PHP
$long_url = rawurldecode($_GET['link']);
echo $long_url;
api.php? link = link
I am making an API to shorten links, the links I use could not get the rest of the url after the & sign.
<?PHP
$long_url = rawurldecode($_GET['link']);
echo $long_url;
api.php? link = link
The link that will be sent by GET must be text-encoded, otherwise GET will understand each link option as subqueries.
For example if you give var_dump($_GET);
You will get the following result:
array (size=3)
'link' => string 'http://iptv.clanspeak.com.br:15000/get.php?username=USER' (length=56)
'passwordPASS' => string 'm3u_plus' (length=8)
'output' => string 'ts' (length=2)
The encoded format of your link should look like this:
api.php?link=http%3A%2F%2Fiptv.clanspeak.com.br%3A15000%2Fget.php%3Fusername%3DUSER%26passwordPASS%3Dm3u_plus%26output%3Dts
And then yes, that way you could do what you want.
To make the correct coding of links in php you can use the following command before sending the url to the link of your api:
htmlentities(urlencode('seulinkaqui'))
and via javascript you can use encodeURIComponent
: