public function run() { $this->beforeRun(); $CURL = new CURL(); $url = 'https://api.spotify.com/v1/artists/' . $this->config->id; // if anything happens during requests return a false // it could be that the artist’s id is wrong or the server is not // responding $result = $CURL->get($url); if (!$result) { return false; } // response does not contain valid json that can be transformed to array if (!($json = json_decode($result, true))) { return false; } // if an error occures return just false if (isset($json['error'])) { return false; } // try to find the artists popularity if (!isset($json['popularity'])) { return false; } return $this->convertValue($json['popularity']); }
public function run() { $this->beforeRun(); $query = array('id' => $this->config->id, 'country' => $this->config->country, 'entity' => 'software'); if (preg_match('/^\\d+$/', $this->config->id)) { $baseUrl = 'https://itunes.apple.com/lookup'; $query['id'] = $this->config->id; } else { $baseUrl = 'https://itunes.apple.com/search'; $query['term'] = $this->config->id; $query['entity'] = 'software'; } $CURL = new CURL(); if (!($result = $CURL->get($baseUrl, $query))) { return 0; } // check the response format if (!($json = json_decode($result, true))) { return 0; } // always take the first result if (!isset($json['results']) || !isset($json['results'][0])) { return 0; } $data = $json['results'][0]; // extract the data if (isset($data[$this->config->key])) { return (double) $data[$this->config->key]; } return 0; }
public function run() { $this->beforeRun(); $url = "https://de.foursquare.com/v/" . $this->config->venue; $CURL = new CURL(); if (!($response = $CURL->get($url))) { return 0; } // the international result of a foursquare venue contains json encoded // information about varios venues, we need the id of the current venue // to get the counters for that venue instead of any other $venueId = substr($this->config->venue, strpos($this->config->venue, '/') + 1); // capture data from the javascript json from the page’s source $data = array(); $regexps = array('checkins' => '/' . $venueId . '.*checkinsCount":(\\d+)/', 'people' => '/' . $venueId . '.*usersCount":(\\d+)/'); foreach ($regexps as $key => $regexp) { if (!preg_match($regexp, $response, $matches)) { $value = 0; } else { $value = (int) $matches[1]; } $data[$key] = $value; } // return the value that was desired in the config return $data[$this->config->key]; }
public function run() { $url = 'http://gdata.youtube.com/feeds/api/videos?q=' . $this->config->id . '&v=2&alt=jsonc'; $CURL = new CURL(); $result = $CURL->get($url); if ($result && ($data = json_decode($result, true))) { return (double) $data['data']['items'][0][$this->config->key]; } return 0; }
public function run() { $this->beforeRun(); $curl = new CURL(); $response = $curl->get($this->config->url); if ($result = $this->processResponse($response)) { $result = $this->convertValue($result); } return $result; }
public function run() { $this->beforeRun(); $url = sprintf('https://www.youtube.com/user/%s/about', $this->config->username); $CURL = new CURL(array(CURLOPT_HTTPHEADER => array('Accept-Language' => 'en_us'))); $response = $CURL->get($url); if ($result = $this->processResponse($response)) { $result = $this->convertValue($result); } return $result; }
public function run() { $this->beforeRun(); $this->config->validate(); $CURL = new CURL(); $response = $CURL->get('https://www.facebook.com/' . $this->config->id . '/likes'); if ($response && preg_match('/\\[\\{"__m":"m_0_8"\\},([\\d\\.]+)/i', $response, $matches)) { return $this->convertValue($matches[1]); } return false; }
public function run() { $this->beforeRun(); $url = 'https://api.github.com/users/' . $this->config->username; $CURL = new CURL(); $result = $CURL->get($url); if ($result && ($data = json_decode($result, true))) { return (int) $data[$this->config->key]; } return 0; }
public function run() { $this->beforeRun(); $CURL = new CURL(); $data = array('query' => sprintf('select total_count,like_count,comment_count,share_count,click_count from link_stat where url="%s"', $this->config->url), 'format' => 'json'); $response = $CURL->get('http://api.facebook.com/method/fql.query', $data); if (($json = json_decode($response, true)) && isset($json[0][$this->config->type])) { return (double) $json[0][$this->config->type]; } return false; }
public function run() { $this->beforeRun(); $url = sprintf('http://www.xboxgamertag.com/search/%s/', $this->config->username); $CURL = new CURL(); $response = $CURL->get($url); if ($result = $this->processResponse($response)) { $result = $this->convertValue($result); } return $result; }
public function run() { $this->beforeRun(); $this->config->validate(); $CURL = new CURL(); $response = $CURL->get('http://graph.facebook.com/' . $this->config->id); if ($json = json_decode($response, true)) { return (int) $json[$this->config->key . '_active_users']; } return false; }
public function run() { $this->beforeRun(); $CURL = new CURL(); $url = 'http://apps.compete.com/sites/' . $this->config->host . '/trended/' . $this->config->metric . '/?apikey=' . $this->config->api_key; $response = $CURL->get($url); if (($json = json_decode($response, true)) && $json['status'] == 'OK') { $lastMonth = array_pop($json['data']['trends'][$this->config->metric]); return (double) $lastMonth['value']; } return false; }
public function run() { $this->beforeRun(); $this->config->validate(); $CURL = new CURL(); $url = 'https://www.facebook.com/' . $this->config->id; $response = $CURL->get($url); if ($response && preg_match('/PagesLikesCountDOMID">.+>([\\d\\.]+)/i', $response, $matches)) { return $this->convertValue($matches[1]); } return false; }
public function run() { $this->beforeRun(); $CURL = new CURL(); $result = $CURL->get($this->config->url); if ($result && ($xmlElement = new \SimpleXMLElement($result))) { $foundNodes = $xmlElement->xpath($this->config->xpath); if (isset($foundNodes[0])) { return (double) $foundNodes[0]; } } return 0; }
public function run() { $this->beforeRun(); $CURL = new CURL(); $data = array('s' => $this->config->symbol, 'f' => $this->config->format); $endpoint = 'http://download.finance.yahoo.com/d/quotes.csv'; $result = $CURL->get($endpoint, $data); if (!$result || !($data = explode(',', $result))) { var_dump($result); return 0; } return (double) $data[0]; }
public function run() { $this->beforeRun(); $url = 'http://vimeo.com/api/v2/' . $this->config->username . '/info.json'; $CURL = new CURL(); $result = $CURL->get($url); if ($result) { $json = json_decode($result, true); if (isset($json['total_' . $this->config->key])) { return $json['total_' . $this->config->key]; } } return 0; }
public function run() { $this->beforeRun(); $url = 'http://api.soundcloud.com/users/' . $this->config->username . '.json'; $CURL = new CURL(); $result = $CURL->get($url, array('consumer_key' => 'aecdbad067b1f60f765db9a16af53cc4')); if ($result) { $json = json_decode($result, true); if (isset($json[$this->config->key . '_count'])) { return (int) $json[$this->config->key . '_count']; } } return 0; }
public function run() { $this->beforeRun(); $url = 'http://vimeo.com/api/v2/video/' . $this->config->id . '.json'; $CURL = new CURL(); $result = $CURL->get($url); if ($result) { $json = json_decode($result, true); if (isset($json[0]['stats_number_of_' . $this->config->key])) { return (int) $json[0]['stats_number_of_' . $this->config->key]; } } return 0; }
public function run() { $CURL = new CURL(array(CURLOPT_HTTPHEADER => array('Content-type: application/json'), CURLOPT_RETURNTRANSFER => 3, CURLOPT_SSL_VERIFYPEER => false)); $postData = '[{"method":"pos.plusones.get","id":"p","params":{"nolog":true,"id":"' . $this->config->url . '","source":"widget","userId":"@viewer","groupId":"@self"},"jsonrpc":"2.0","key":"p","apiVersion":"v1"}]'; $result = $CURL->post('https://clients6.google.com/rpc', $postData); // some network errors if (!$result) { return false; } // json decode $data = json_decode($result, true); if (!isset($data[0]['result'])) { return false; } return (int) $data[0]['result']['metadata']['globalCounts']['count']; }
protected function getUserFlattrs($username) { $CURL = new CURL(); $source = $CURL->get('http://api.flattr.com/button/view/', array('url' => 'https://flattr.com/profile/' . $this->config->username)); if ($source) { $DOMDocument = new \DOMDocument(); $DOMDocument->loadHTML($source); $DOMXPath = new \DOMXPath($DOMDocument); $nodes = $DOMXPath->query('//span[@class="flattr-count"]/span'); if ($nodes->length > 0) { foreach ($nodes as $node) { return $node->textContent; } } } return 0; }
public function run() { $this->beforeRun(); switch ($this->config->key) { case 'total_downloads': $urlTemplate = 'https://wordpress.org/plugins/%s/'; break; case 'downloads_yesterday': $urlTemplate = 'https://api.wordpress.org/stats/plugin/1.0/downloads.php?slug=%s&limit=267&callback=?'; break; default: $urlTemplate = 'http://wpapi.org/api/plugin/%s.json'; break; } $url = sprintf($urlTemplate, urlencode($this->config->slug)); $curl = new CURL(); $response = $curl->get($url); if ($result = $this->processResponse($response)) { $result = $this->convertValue($result); } return $result; }
public function run() { $this->beforeRun(); $url = "http://www.slideshare.net/" . urlencode($this->config->username); $CURL = new CURL(); if (!($response = $CURL->get($url))) { return 0; } // capture data from the javascript json from the page’s source $data = array(); $regexps = array('followers' => '/(\\d+) Follower/', 'slides' => '/(\\d+) SlideShares/'); foreach ($regexps as $key => $regexp) { if (!preg_match($regexp, $response, $matches)) { $value = 0; } else { $value = (int) $matches[1]; } $data[$key] = $value; } // return the value that was desired in the config return $data[$this->config->key]; }
public function run() { $this->beforeRun(); $endpoint = 'https://api.github.com/repos/'; $url = $endpoint . $this->config->username . '/' . $this->config->repository; if (strtolower($this->config->key) == 'sloc') { $url .= '/languages'; } $CURL = new CURL(); $result = $CURL->get($url); // something in the response went wrong if (!$result) { return false; } if (!($data = json_decode($result, true))) { return false; } if (isset($data['message'])) { switch ($data['message']) { case 'Not Found': return false; break; default: break; } } // sloc count sums up the json response if ($this->config->key == 'sloc') { return array_sum($data); } // other keys may need mapping $keypmapping = array('stargazers' => 'stargazers_count', 'watchers' => 'watchers_count', 'forks' => 'forks_count', 'open_issues' => 'open_issues', 'size' => 'size'); if (!isset($keypmapping[$this->config->key])) { return false; } $mappedKey = $keypmapping[$this->config->key]; return (int) $data[$mappedKey]; }
public function run() { $this->beforeRun(); $CURL = new CURL(); $source = $CURL->get('http://api.bf3stats.com/' . $this->config->platform . '/player/', array('player' => $this->config->username)); if (!$source || !($json = json_decode($source, true))) { return null; } if (empty($json['stats'])) { return null; } switch (strtolower($this->config->metric)) { default: $avlue = 0; break; case 'skill': case 'elo': $value = $json['stats']['global']['elo']; break; case 'score': $value = $json['stats']['scores']['score']; break; case 'spm': $value = $json['stats']['scores']['score'] / $json['stats']['global']['time'] * 60; break; case 'rounds': $value = $json['stats']['global']['rounds']; break; case 'finished-rounds': $value = $json['stats']['global']['elo_games']; break; case 'wins': $value = $json['stats']['global']['wins']; break; case 'losses': $value = $json['stats']['global']['losses']; break; case 'wlratio': $value = $json['stats']['global']['losses'] / $json['stats']['global']['wins']; break; case 'kills': $value = $json['stats']['global']['kills']; break; case 'deaths': $value = $json['stats']['global']['deaths']; break; case 'kdratio': $value = $json['stats']['global']['deaths'] / $json['stats']['global']['kills']; break; case 'headshots': $value = $json['stats']['global']['headshots']; break; case 'shots': $value = $json['stats']['global']['shots']; break; case 'hits': $value = $json['stats']['global']['hits']; break; case 'accuracy': $value = $json['stats']['global']['shots'] / $json['stats']['global']['hits']; break; } return (double) preg_replace('@[^0-9\\.]+@', '', $value); }