PHP: Kugwiritsa ntchito Is.gd API kuti mufupikitse URL

Zithunzi za Depositph 11843590 s

Ingowerengani nkhani yonena za maubwino ndi misampha ya kufupikitsa ma URL pa SEOmoz. Ndimagwiritsa ntchito Is.gd API kuti muchite izi ndi Pulogalamu ya SMS WordPress zomwe ndidalemba (pakadali pano ndikuyesa ndikuchita bwino!).

ntchito doCurlRequest ($ url, $ variable, $ value) {$ api = $ url. "?". $ variable. "=". $ mtengo; $ gawo = curl_init (); curl_setopt ($ gawo, CURLOPT_URL, $ api); curl_setopt ($ gawo, CURLOPT_RETURNTRANSFER, 1); $ data = curl_exec ($ gawo); curl_close ($ gawo); bweretsani data ya $; } ntchito doShortenURL ($ longurl) {$ url = "http://is.gd/api.php"; $ kusiyanitsa = "longurl"; $ shorturl = doCurlRequest ($ url, $ variable, $ longurl); bweretsani $ shorturl; }

Mukuganiza kuti inu anthu mungayamikire mtundu weniweni wamakalata. Onetsetsani kuti mwasintha zolemba zomwe zidatumizidwa ndikulemba izi ku blog. Kuti mugwiritse ntchito, ingowonjezerani ntchito zomwe zili pamwambapa patsamba lanu la PHP ndikuchita motere:

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

Ndingowonjezerapo choyesa / chotsimikizira kuti ndingotsimikiza. Khodi iyi imagwira ntchito ndi PHP 5+ pomwe ili ndi laibulale ya cURL. Ngati wolandila wanu sakuthandizira cURL, pezani alendo atsopano.

Mfundo imodzi

  1. 1

Mukuganiza chiyani?

Tsambali likugwiritsa ntchito Akismet kuchepetsa spam. Phunzirani momwe deta yanu ikufotokozera.