Esempio n. 1
0
 public static function shortenUrl($link)
 {
     $tinyUrlApiPrefix = 'http://tinyurl.com/api-create.php?url=';
     $shortLink = RemoteHelper::getRemote($tinyUrlApiPrefix . $link);
     if (!$shortLink) {
         $shortLink = $link;
     }
     return $shortLink;
 }
Esempio n. 2
0
 /**
  * Gets the response header from fb picture 
  * and returns the id for that image
  * @param type $url 
  * @return type String 
  */
 public static function getFbPictureId($url)
 {
     $server_output = RemoteHelper::getRemote($url, true);
     if (!$server_output) {
         return 'xxxxxxxxxx';
     }
     //give me everything after the words location and before the new line
     $pattern = "/Location:\\shttp:\\/\\/(.+)*/";
     preg_match($pattern, $server_output, $matches);
     // in case the file_get_contents on the above method
     // does not follow redirects for any reason
     // we can always use this as a curl method
     $prefix = "http://";
     $fullpath = $prefix . $matches[1];
     $path_parts = explode("/", $fullpath);
     $last_index = count($path_parts) - 1;
     return $path_parts[$last_index];
 }