verkort url

Gestart doorLars13 reacties41 weergaven

14 berichten · pagina 1 van 1

Lars

Lid · Topicstarter

Berichten
3.416
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hallo,

Ik wil in me site dat hij automatisch enkel links verkort zoals bijvoorbeeld bit.ly links.
Zodat ik ze makkelijk op andere sites kan plaatsen weet iemand of dit mogelijk is met 1 of andere api of scriptje ?
Zie wel veel sites die bit.ly ervoor gebruiken maar kom niet uit die api..
0
Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Moet je de links zelf invoeren: http://tinyurl.com/
0
Lars

Lid · Topicstarter

Berichten
3.416
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Josnl schreef:
Moet je de links zelf invoeren: http://tinyurl.com/
Ik wil dus dat het automatisch gaat ga niet voor zon 1000 links dat invoeren..
0
Berichten
3.461
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ow, okee dan heb ik je verkeerd begrepen hypocrite!

Misschien kan het met .htacces, en dan met Rewrite(...), ik zal het even voor je opzoeken! biggrin
0
Berichten
8.602
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php
$verkorte_url[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/file_get_contents"]file_get_contents[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]http://tinyurl.com/api-create.php?url=http://www.url.nl[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$verkorte_url[/COLOR][COLOR= #007700];[/COLOR]
?>
0
Lars

Lid · Topicstarter

Berichten
3.416
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Milan schreef:
[COLOR= #0000BB]<?php
$verkorte_url[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/file_get_contents"]file_get_contents[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]http://tinyurl.com/api-create.php?url=http://www.url.nl[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$verkorte_url[/COLOR][COLOR= #007700];[/COLOR]
?>
Bedankt dat werkt smile
0
Berichten
8.602
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Geen probleem smile
0
Lars

Lid · Topicstarter

Berichten
3.416
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Milan schreef:
Geen probleem smile
Ik wist niet dat hun zon makkelijke api hadden.
Ik had wel is op die site gekeken maar niet gezien. en bij bit.ly had je een documentatie van heel wat blaadjes erbij
0
Erik

Lid

Berichten
7.109
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Of korter:

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [URL="http://www.php.net/file_get_contents"]file_get_contents[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]http://tinyurl.com/api-create.php?url=http://www.url.nl[/COLOR][COLOR= #007700]);[/COLOR]
?>

biggrin.
0
Krm

Lid

Berichten
6.235
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
hoe moet iemand de url dan zien erik
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Wat bedoel je?
als je die code gebruikt staat de link er
0
Erik

Lid

Berichten
7.109
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Precies. biggrin
0
Lars

Lid · Topicstarter

Berichten
3.416
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik gebruik de code van Milan en die werkt erg goed..
En of die dan 1 regel korter kan maakt me niet zo heel veel uit dan wordt het voor mij onoverzichtelijker smile dus ik ben blij met dit
0
Berichten
1.544
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Of mijnes:

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<br /><br /><div id="msg">[/COLOR][COLOR= #007700];[/COLOR]
        [COLOR= #0000BB]$url[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]url[/COLOR][COLOR= #007700]];[/COLOR]
        [COLOR= #0000BB]$ch[/COLOR] [COLOR= #007700]=[/COLOR] curl_init[COLOR= #007700]();[/COLOR]
        curl_setopt [COLOR= #007700]([/COLOR][COLOR= #0000BB]$ch[/COLOR][COLOR= #007700],[/COLOR] CURLOPT_URL[COLOR= #007700],[/COLOR] [COLOR= #DD0000]http://je7.eu/api.php[/COLOR][COLOR= #007700]);[/COLOR]
        curl_setopt [COLOR= #007700]([/COLOR][COLOR= #0000BB]$ch[/COLOR][COLOR= #007700],[/COLOR] CURLOPT_RETURNTRANSFER[COLOR= #007700],[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]);[/COLOR]
        curl_setopt[COLOR= #007700]([/COLOR][COLOR= #0000BB]$ch[/COLOR][COLOR= #007700],[/COLOR] CURLOPT_POST[COLOR= #007700],[/COLOR] true[COLOR= #007700]);[/COLOR]
        curl_setopt[COLOR= #007700]([/COLOR][COLOR= #0000BB]$ch[/COLOR][COLOR= #007700],[/COLOR] CURLOPT_POSTFIELDS[COLOR= #007700],[/COLOR] [COLOR= #DD0000]"url="[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/urlencode"]urlencode[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$url[/COLOR][COLOR= #007700]));[/COLOR]
        [COLOR= #0000BB]$html[/COLOR] [COLOR= #007700]=[/COLOR] curl_exec[COLOR= #007700]([/COLOR][COLOR= #0000BB]$ch[/COLOR][COLOR= #007700]);[/COLOR]
        curl_close[COLOR= #007700]([/COLOR][COLOR= #0000BB]$ch[/COLOR][COLOR= #007700]);[/COLOR]
        [URL="http://www.php.net/preg_match"]preg_match[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]/<error>(.*?)</error>/[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]$html[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]$melding[/COLOR][COLOR= #007700]);[/COLOR]
        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700](![/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$melding[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]1[/COLOR][COLOR= #007700]])){[/COLOR]
            [COLOR= #0000BB]$errorcode[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$melding[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]1[/COLOR][COLOR= #007700]];[/COLOR]
            [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$errorcode[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]100[/COLOR][COLOR= #007700]){[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]U heeft geen URL ingevult[/COLOR][COLOR= #007700];
            }[/COLOR][URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$errorcode[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]200[/COLOR][COLOR= #007700]){[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]U heeft geen geldige URL ingevult[/COLOR][COLOR= #007700];
            }[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Er is een onbekende fout opgetreden[/COLOR][COLOR= #007700];
            }
        }[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
            [URL="http://www.php.net/preg_match"]preg_match[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]/<url>(.*?)</url>/[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]$html[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]$melding[/COLOR][COLOR= #007700]);[/COLOR]
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<a href="[/COLOR][COLOR= #007700];[/COLOR]
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$melding[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]1[/COLOR][COLOR= #007700]];[/COLOR]
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]" target="_blank">[/COLOR][COLOR= #007700];[/COLOR]
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$melding[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]1[/COLOR][COLOR= #007700]];[/COLOR]
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]</a>[/COLOR][COLOR= #007700];
        }[/COLOR]
?>
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren