PHP: Ma te whakamahi i Is.gd API ki te Whakapoto i te URL

Depositphotos 11843590 s

Panuihia noa te tuhinga mo nga painga me nga raru o whakapoto URL i runga i SEOmoz. Ka whakamahi ahau i te Is.gd API ki te mahi i tenei ki te Mono WordPress WordPress i tuhia e au (i tenei wa kei te whakamatautau me te pai!).

mahi doCurlRequest ($ url, $ variable, $ value) {$ api = $ url. "?". $ variable. "=". $ value; $ session = curl_init (); curl_setopt ($ wātū, CURLOPT_URL, $ api); curl_setopt ($ wātū, CURLOPT_RETURNTRANSFER, 1); $ data = curl_exec ($ wātū); curl_close ($ wātū); whakahoki $ raraunga; } mahi doShortenURL ($ longurl) {$ url = "http://is.gd/api.php"; $ variable = "longurl"; $ shorturl = doCurlRequest ($ url, $ taurangi, $ longurl); whakahoki $ shorturl; }

Whakaaro kia mauruuru koutou e patata ana ki te tauira tauira waehere pono. Kia mahara ki te whakakapi i nga korero ngahau e tuku ana i tenei ki te blog taapiri. Hei whakamahi, taapirihia nga mahi o runga ake nei ki to whaarangi PHP ka mahi penei:

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

Ka taapirihia pea e au he poraka whakamatautau / hopu kia mohio ai koe. Ka mahi tenei waehere ma te PHP 5+ me te whare pukapuka cURL kua whakahohea. Mena kaore e taea e to kaihautu te whakahohe i te cURL, kimihia he kaihautu hou.

kotahi kōrero

  1. 1

He aha koutou whakaaro?

Whakamahia ai e tenei pae i te Akismet hei whakaiti i te mokowhiti. Akohia te tukatuka o to raraunga korero.