I-PHP: Sebenzisa u-Is.gd API Ukunciphisa i-URL

Iidipozithi iifoto 11843590 s

Funda nje inqaku malunga nezibonelelo kunye nemingxunya ye ukunciphisa ii-URL ngaphezulu kwe-SEOmoz. Ndisebenzisa i Is.gd API ukwenza oku nge Iplagi efakiweyo yeSMS WordPress endikubhalileyo (ukuvavanya okwangoku kunye nokwenza kakuhle!).

sebenza doCurlRequest ($ url, $ variable, $ value) {$ api = $ url. "?". $ variable. "=". Ixabiso lexabiso; Iseshoni yeedola = curl_init (); curl_setopt (iseshoni ye- $, CURLOPT_URL, $ api); curl_setopt (iseshoni ye- $, CURLOPT_RETURNTRANSFER, 1); Idatha yedatha = curl_exec (iseshoni yeedola); curl_close (iseshoni yeedola); buyisela idatha yedola; } umsebenzi doShortenURL ($ longurl) {$ url = "http://is.gd/api.php"; Umahluko $ = "longurl"; $ shorturl = doCurlRequest ($ url, $ variable, $ longurl); buyisela i- $ shorturl; }

Ndicinga ukuba bantu bangayixabisa eyona khowudi isampulu. Qiniseka ukuba uyasitshintsha isicatshulwa esenziwe ngokuthumela oku kwibhlog. Ukuze usebenzise, ​​yongeza nje le misebenzi ingentla kwiphepha lakho le-PHP emva koko wenze ngolu hlobo:

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

Ndingadibanisa ukuzama / ukubamba ibhloko ukuze ndiqiniseke. Le khowudi isebenza nge-PHP 5+ kunye nelayibrari ye-cURL enikwe amandla. Ukuba umbuki zindwendwe wakho akenzi ukuba i-cURL isebenze, fumana umamkeli omtsha.

enye izimvo

  1. 1

Ingaba ucinga ntoni?

Le sayithi isebenzisa i-Akismet ukunciphisa ugaxekile. Funda indlela idatha yakho yokubhaliweyo isetyenziswe ngayo.