PHP: Ho sebelisa Is.gd API ho Khutsufatsa URL

Litšoantšo tsa Depositph 11843590 s

Bala feela sengoloa ka melemo le maraba a ho khutsufatsa li-URL ho feta SEOmoz. Ke sebelisa the Is.gd API ho etsa sena ka Sesebelisoa sa WordPress sa WordPress seo ke se ngotseng (ha joale ke ntse ke leka le ho etsa hantle!).

sebetsa doCurlRequest ($ url, $ variable, $ value) {$ api = $ url. "?". $ variable. "=". $ value; Seboka sa $ = curl_init (); curl_setopt (seboka sa $, CURLOPT_URL, $ api); curl_setopt (seboka sa $, CURLOPT_RETURNTRANSFER, 1); $ data = curl_exec (thuto ea $); curl_close ($ thuto); khutlisa data ea $; } mosebetsi doShortenURL ($ longurl) {$ url = "http://is.gd/api.php"; $ ho fetoha = "longurl"; $ shorturl = doCurlRequest ($ url, $ variable, $ longurl); khutlisa $ shorturl; }

Ke nahana hore lona batho le kanna la ananela sampole ea 'nete. Etsa bonnete ba hore o nka sebaka sa litlatsetso tse tsebahalang tse romellang blog ena. Ho e sebelisa, eketsa feela mesebetsi e kaholimo ho leqephe la hau la PHP ebe u phethisa tjena:

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

Ke kanna ka eketsa leka / ho ts'oara feela ho netefatsa. Khoutu ena e sebetsa le PHP 5+ ka laeborari ea cURL e lumelletsoe. Haeba moamoheli oa hau a sa khone cURL, fumana moamoheli e mocha.

ba fane ka tlhaloso e le 'ngoe

  1. 1

U nahana eng?

Sebaka sena se sebelisa Akismet ho fokotsa spam. Ithute kamoo litlhaloso tsa hau li hlahang kateng.