Example #1
0
 /**
  * @param $url
  * @param $matches
  * @return array
  */
 private function vimeoFormat($url)
 {
     $re = "/https?:\\/\\/(?:www\\.|player\\.)?vimeo.com\\/" . "(?:channels\\/(?:\\w+\\/)?|groups\\/([^\\/]*)\\/videos\\/" . "|album\\/(\\d+)\\/video\\/|video\\/|)(\\d+)(?:\$|\\/|\\?)?/";
     preg_match_all($re, $url, $matches);
     if (!$matches[3]) {
         return false;
     }
     $imgId = $matches[3][0];
     $hash = json_decode($this->http->get("http://vimeo.com/api/v2/video/{$imgId}.json"));
     return ['url' => "http://player.vimeo.com/video/{$imgId}", 'thumbnail' => $hash[0]->thumbnail_large];
 }
Example #2
0
 /**
  * Retrieve response from cache if it exists otherwise make a GET request.
  *
  * @param  string $endpoint      Request endpoint.
  * @param  string $root_property The theme/plugin slug or WordPress version.
  *
  * @return SSNepenthe\Soter\WPVulnDB\Response
  *
  * @throws \InvalidArgumentException When endpoint is not a string.
  * @throws \InvalidArgumentException When root_property is not a string.
  */
 protected function get_and_cache($endpoint, $root_property)
 {
     if (!is_string($endpoint)) {
         throw new \InvalidArgumentException(sprintf('The endpoint parameter is required to be string, was: %s', gettype($endpoint)));
     }
     if (!is_string($root_property)) {
         throw new \InvalidArgumentException(sprintf('The root_property parameter is required to be string, was: %s', gettype($root_property)));
     }
     if ($this->cache->contains($endpoint)) {
         return new Response($this->cache->fetch($endpoint), $root_property);
     }
     $response = $this->http->get($endpoint);
     // @todo Filterable cache lifetime?
     $this->cache->save($endpoint, $response, 60 * 60 * 12);
     return new Response($response, $root_property);
 }