/** Uses the Graph API to get likes for a URI @param $uri the URI to check @return like count */ function like_count($uri) { $res = radix_http::get('http://graph.facebook.com/?ids=' . rawurlencode($uri)); if ($res['info']['http_code'] == 200) { $res = json_decode($res['body'], true); return intval($res[$uri]['shares']); } }
/** @param $a the token passed back from the oAuth Provider, typically $_GET['oauth_token'] */ public function getAccessToken($a = null) { $uri = self::TOKEN_ACCESS_URI; $arg = array('client_id' => $this->_oauth_client_id, 'client_secret' => $this->_oauth_client_secret, 'grant_type' => 'authorization_code', 'redirect_uri' => $a['redirect_uri'], 'code' => $a['code']); $res = radix_http::get($uri . '?' . http_build_query($arg)); radix::dump($res); $ret = json_decode($res['body'], true); return $ret; }
/** Easy Wrapper for Fetch */ function api($uri, $post = null) { $uri = sprintf('%s/%s', self::API_URI, trim($uri, '/')); if (!empty($post)) { die('I do not handle this yet'); } $res = radix_http::get($uri, array('Authorization: ' . $this->_access_token)); $type = strtok($res['info']['content_type'], ';'); if ($type == 'application/json') { $res = json_decode($res['body'], true); } return $res; }
/** Easy Wrapper for Fetch */ function api($uri, $post = null, $head = null) { $verb = 'GET'; // $post = array(); // $post = array( // 'format' => 'json', // ); $uri = self::API_URI . ltrim($uri, '/') . '?access_token=' . $this->_access_token; // $ret = $this->fetch($uri,$post,$verb,$head); if (!empty($post)) { die('I do not handle this yet'); } $res = radix_http::get($uri); if ($res['info']['content_type'] == 'application/json') { $res = json_decode($res['body'], true); } return $res; }
public function statApplication($sid) { $api = sprintf('/Applications/%s.json', $sid); $res = radix_http::get($this->_base . $api); $ret = json_decode($res['body'], true); return $ret; }