Go to the documentation of this file.00001 <?php
00012 class helper_bitLy extends object {
00013
00019 protected function getDefPrm() {
00020 return $this->cfg->param;
00021 }
00022
00030 protected function doAction($action, array $prm) {
00031 $prm = array_merge($this->getDefPrm(), $prm);
00032 $url = $this->cfg->url.$action.'?';
00033 foreach($prm as $k=>$v)
00034 $url.= $k.'='.$v.'&';
00035 $content = file_get_contents($url);
00036 if ($content)
00037 return json_decode($content);
00038 }
00039
00046 public function shorten($longUrl) {
00047 $content = $this->doAction('shorten', array('longUrl'=>$longUrl));
00048 if ($content->statusCode == 'OK') {
00049 return $content->results->$longUrl->shortUrl;
00050 }
00051 return null;
00052 }
00053
00054 }