Example #1
0
 public function getFeeds($username, $accessToken, $limit = 20)
 {
     $url = "https://graph.facebook.com/" . $username . "/feed?access_token=" . $accessToken;
     try {
         $http = RedHttpFactory::getHttp();
         $response = $http->get($url);
         $feedData = json_decode($response->body);
         if (isset($feedData->error)) {
             return "";
         }
         return $feedData;
     } catch (Exception $e) {
         return "";
     }
 }
Example #2
0
 public function getUserTimeline($username, $accessToken, $limit = 20)
 {
     $url = "https://api.twitter.com/1.1/statuses/user_timeline.json?include_rts=1&screen_name=" . $username . "&count=" . $limit;
     $header = array('Authorization' => $accessToken);
     try {
         $http = RedHttpFactory::getHttp();
         $response = $http->get($url, $header);
         $userTimlines = json_decode($response->body);
         if (isset($userTimlines->error)) {
             return "";
         }
         return $userTimlines;
     } catch (Exception $e) {
         return "";
     }
 }
Example #3
0
 /**
  * @param $consumer_key
  * @param $consumer_secret
  */
 public static function getAccessToken($consumer_key, $consumer_secret)
 {
     // Bearer token credentials
     $consumer_key = str_replace('+', ' ', str_replace('%7E', '~', rawurlencode($consumer_key)));
     $consumer_secret = str_replace('+', ' ', str_replace('%7E', '~', rawurlencode($consumer_secret)));
     $header = array('Authorization' => 'Basic ' . base64_encode($consumer_key . ":" . $consumer_secret), 'Content-type' => 'application/x-www-form-urlencoded; charset=UTF-8');
     $data = array('grant_type' => 'client_credentials');
     try {
         $http = RedHttpFactory::getHttp();
         $response = $http->post(self::$access_token_url, $data, $header);
         $access_data = json_decode($response->body);
         if (isset($access_data->errors)) {
             return "";
         }
         return $access_data->access_token;
     } catch (Exception $e) {
         return "";
     }
 }
Example #4
0
 public static function getUserTimeline($username, $cacheTweets, $count = 20)
 {
     $url = "https://api.twitter.com/1.1/statuses/user_timeline.json?include_rts=1&screen_name=" . $username . "&count=" . $count;
     $header = array('Authorization' => self::$oauthInfo->access_token);
     $http = RedHttpFactory::getHttp();
     $response = $http->get($url, $header);
     if (!empty(self::$params) && self::$params->get('cache') == 1) {
         try {
             file_put_contents($cacheTweets, $response->body);
         } catch (Exception $e) {
         }
     }
     return json_decode($response->body);
 }
Example #5
0
 /**
  * Constructor.
  *
  * @param   JRegistry       $options    Client options object. If the registry contains any headers.* elements,
  *                                      these will be added to the request headers.
  * @param   JHttpTransport  $transport  The HTTP transport object.
  *
  * @since   11.3
  */
 public function __construct(JRegistry $options = null, RedHttpTransport $transport = null)
 {
     $this->options = isset($options) ? $options : new JRegistry();
     $this->transport = isset($transport) ? $transport : RedHttpFactory::getAvailableDriver($this->options);
 }
Example #6
0
 public static function requestLinkedinAccessToken($cliendId, $cliendSecret, $callbackUrl, $code)
 {
     $data = array('grant_type' => 'authorization_code', 'code' => $code, 'client_id' => $cliendId, 'client_secret' => $cliendSecret, 'redirect_uri' => $callbackUrl);
     try {
         $http = RedHttpFactory::getHttp();
         $response = $http->post(self::$_linkedinAccessTokenUrl, $data);
         $accessData = json_decode($response->body);
         if (isset($accessData->error)) {
             return "";
         }
         return $accessData->access_token;
     } catch (Exception $e) {
         return "";
     }
 }