nyroFwk  0.2
bitLy.class.php
Go to the documentation of this file.
1 <?php
12 class helper_bitLy extends object {
13 
19  protected function getDefPrm() {
20  return $this->cfg->param;
21  }
22 
30  protected function doAction($action, array $prm) {
31  $prm = array_merge($this->getDefPrm(), $prm);
32  $url = $this->cfg->url.$action.'?';
33  foreach($prm as $k=>$v)
34  $url.= $k.'='.$v.'&';
35  $content = file_get_contents($url);
36  if ($content)
37  return json_decode($content);
38  }
39 
46  public function shorten($longUrl) {
47  $content = $this->doAction('shorten', array('longUrl'=>$longUrl));
48  if ($content->statusCode == 'OK') {
49  return $content->results->$longUrl->shortUrl;
50  }
51  return null;
52  }
53 
54 }
shorten($longUrl)
Definition: bitLy.class.php:46
doAction($action, array $prm)
Definition: bitLy.class.php:30
Generated on Sun Oct 15 2017 22:25:20 for nyroFwk by doxygen 1.8.13