PHP: Uchishandisa Is.gd API kupfupisa URL

Depositphotos 11843590 s

Ingoverenga chinyorwa pane zvakanakira uye misungo ye kupfupisa ma URL pamusoro peSEOmoz. Ini ndinoshandisa iyo Is.gd API kuita izvi ne SMSPress Plugin izvo zvandanyora (parizvino kuyedza uye kuita mushe!).

shanda doCurlRequest ($ url, $ variable, $ value) {$ api = $ url. "?". $ variable. "=". $ kukosha; $ chikamu = curl_init (); curl_setopt ($ chikamu, CURLOPT_URL, $ api); curl_setopt ($ chikamu, CURLOPT_RETURNTRANSFER, 1); $ data = curl_exec ($ chikamu); curl_close ($ chikamu); dzosera $ data; } basa doShortenURL ($ longurl) {$ url = "http://is.gd/api.php"; $ kusiyanisa = "longurl"; $ shorturl = doCurlRequest ($ url, $ kusiana, $ longurl); dzosera $ shorturl; }

Ndakafunga imi vanhu kuti mukoshese chaiyo kodhi yemuenzaniso. Ive neshuwa kutsiva iwo akadzidziswa makotesheni ayo kutumira izvi kublog kunowedzera. Kuti ushandise, ingo wedzera mabasa ari pamusoro apa kune yako PHP peji wozoita seizvi:

doShortenURL ('http://thisis.my/long/url/with?lots=of&data=');

Ini ndingangodaro ndawedzera yekuyedza / kubata block kungova nechokwadi. Iyi kodhi inoshanda nePHP 5+ neiyo cURL raibhurari inogoneswa. Kana muenzi wako asingagone cURL, tsvaga new host.

Pfungwa

  1. 1

Unofungei?

Nzvimbo iyi inoshandisa Akismet kuderedza spam. Dzidza kuti sei deta yako inoshandiswa.