public function getData($path, array $parameters = array()) { $key = JFBCFactory::config()->get('meetup_widget_api_key'); $parameters = array_merge($this->parameters, $parameters, array('key' => $key)); if (preg_match_all('/:([a-z]+)/', $path, $matches)) { foreach ($matches[0] as $i => $match) { if (isset($parameters[$matches[1][$i]])) { $path = str_replace($match, $parameters[$matches[1][$i]], $path); unset($parameters[$matches[1][$i]]); } else { if (JFBCFactory::config()->get('facebook_display_errors')) { JFBCFactory::log("Meetup Widget Error: Missing parameter '" . $matches[1][$i] . "' for path '" . $path . "'.", 'error'); } } } } $url = self::BASE . $path . '?' . http_build_query($parameters); $data = JFBCFactory::cache()->get('meetup.widget.' . $url); if ($data === false) { $response = $this->getURL($url); if ($response && isset($response->results)) { $data = $response->results; JFBCFactory::cache()->store($data, 'meetup.widget.' . $url); } } return $data; }
function getFeed() { $feedHtml = JFBCFactory::cache()->get('sourcecoast.rss'); if ($feedHtml === false) { $curl = curl_init(); curl_setopt_array($curl, array(CURLOPT_URL => 'http://feeds.sourcecoast.com/sourcecoast-blog', CURLOPT_USERAGENT => 'spider', CURLOPT_TIMEOUT => 120, CURLOPT_CONNECTTIMEOUT => 30, CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_ENCODING => 'UTF-8')); $data = curl_exec($curl); $errorCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); curl_close($curl); if ($data && !empty($data) && $errorCode == 200) { $xml = simplexml_load_string($data, 'SimpleXMLElement', LIBXML_NOCDATA); if ($xml) { $feedHtml = '<h4>Recent News from SourceCoast</h4>'; for ($i = 0; $i < 4; $i++) { if (isset($xml->channel->item[$i])) { $item = $xml->channel->item[$i]; $date = JFactory::getDate($item->pubDate); $dateStr = $date->format(JText::_('DATE_FORMAT_LC4')); $feedHtml .= '<p><a href="' . $item->link . '">' . $item->title . '</a> <span><em>' . $dateStr . '</em></span></p>'; } } } } JFBCFactory::cache()->store($feedHtml, 'sourcecoast.rss'); } return $feedHtml; }
function getAvatarUrl($providerId, $nullForDefault = true, $params = null) { $nullString = $nullForDefault ? 'null' : 'notnull'; $avatarUrl = JFBCFactory::cache()->get('windowslive.avatar.' . $nullString . '.' . $providerId); if ($avatarUrl === false) { $avatarUrl = "https://apis.live.net/v5.0/{$providerId}/picture"; JFBCFactory::cache()->store($avatarUrl, 'windowslive.avatar.' . $nullString . '.' . $providerId); } return $avatarUrl; }
function getProfileUrl($providerUserId) { $profileUrl = JFBCFactory::cache()->get('instagram.profile.' . $providerUserId); $token = $this->provider->client->getToken(); if (!empty($token)) { //instragram token includes user data //get username from token $user = (array) $token['user']; $profileUrl = 'https://instagram.com/' . $user['username']; JFBCFactory::cache()->store($profileUrl, 'instagram.profile.' . $providerUserId); } return $profileUrl; }
function getAvatarUrl($providerUserId, $nullForDefault = false, $params = null) { $avatarUrl = JFBCFactory::cache()->get('twitter.avatar.' . $providerUserId); if ($avatarUrl === false) { $profile = $this->fetchProfile($providerUserId, array('profile_image_url', 'default_profile_image')); if (!$profile->get('default_profile_image', true)) { $avatarUrl = $profile->get('profile_image_url', null); } else { $avatarUrl = null; } JFBCFactory::cache()->store($avatarUrl, 'twitter.avatar.' . $providerUserId); } return $avatarUrl; }
function getProfileUrl($providerUserId) { $profileUrl = JFBCFactory::cache()->get('github.profile.' . $providerUserId); if ($profileUrl === false) { $profile = $this->fetchProfile('user', 'login'); $username = $profile->get('login'); $profileUrl = 'https://github.com/' . $username; if (!$profileUrl) { $profileUrl = null; } JFBCFactory::cache()->store($profileUrl, 'github.profile.' . $providerUserId); } return $profileUrl; }
function getAvatarUrl($userId, $nullForDefault = true, $params = null) { $nullString = $nullForDefault ? 'null' : 'notnull'; $avatarUrl = JFBCFactory::cache()->get('yahoo.avatar.' . $nullString . '.' . $userId); if ($avatarUrl === false) { $response = $this->fetchProfile($userId, "image"); $image = $response->get('image', null); $avatarUrl = $image->imageUrl; if ($nullForDefault && (!$avatarUrl || strpos($avatarUrl, 'https://s.yimg.com/dg/users'))) { $avatarUrl = null; } JFBCFactory::cache()->store($avatarUrl, 'yahoo.avatar.' . $nullString . '.' . $userId); } return $avatarUrl; }
public function getStream($stream) { $pageId = $this->options->get('page_id'); if (!$pageId || $pageId == '--') { return; } $feed = JFBCFactory::cache()->get('facebook.page.stream.' . $pageId); if ($feed === false) { $params = array(); $params['access_token'] = $this->options->get('access_token'); //NOTE: Uncomment to use user access token instead of page access token //$params['access_token'] = JFBCFactory::usermap()->getUserAccessToken($this->options->get('user_id'), 'facebook'); $feed = $this->provider->api($pageId . '/feed?fields=message,from,updated_time,name,link,picture,caption,description,comments', $params, true, 'GET'); JFBCFactory::cache()->store($feed, 'facebook.page.stream.' . $pageId); } if ($feed['data']) { foreach ($feed['data'] as $data) { if (array_key_exists('from', $data) && array_key_exists('message', $data) && ($this->options->get('show_admin_only') == 0 || $data['from']['id'] == $pageId)) { $post = new JFBConnectPost(); if (isset($data['actions'][0])) { $post->link = $data['actions'][0]['link']; } else { $ids = explode("_", $data['id']); $idIndex = count($ids) - 1; $post->link = 'https://www.facebook.com/' . $pageId . '/posts/' . $ids[$idIndex]; } $post->message = array_key_exists('message', $data) ? $data['message'] : ""; $post->authorID = $data['from']['id']; $post->authorScreenName = $data['from']['name']; $post->updatedTime = array_key_exists('updated_time', $data) ? $data['updated_time'] : ""; $post->thumbTitle = array_key_exists('name', $data) ? $data['name'] : ""; $post->thumbLink = array_key_exists('link', $data) ? $data['link'] : ""; $post->thumbPicture = array_key_exists('picture', $data) ? $data['picture'] : ""; $post->thumbCaption = array_key_exists('caption', $data) ? $data['caption'] : ""; $post->thumbDescription = array_key_exists('description', $data) ? $data['description'] : ""; $post->comments = array_key_exists('comments', $data) ? $data['comments'] : ""; $stream->addPost($post); } } } }
function getAvatarUrl($providerUserId, $nullForDefault = true, $params = null) { $nullString = $nullForDefault ? 'null' : 'notnull'; $avatarUrl = JFBCFactory::cache()->get('meetup.avatar.' . $nullString . '.' . $providerUserId); if ($avatarUrl === false) { //get token from the usermap $token = $this->provider->client->getToken(); if (empty($token)) { $token = $this->getUserAccessToken($providerUserId); $this->provider->client->setToken($token); } //meetup doesnt return photo if avatar is not available $profile = $this->fetchProfile($providerUserId, '', 'photo'); $avatarUrl = $profile->get('photo.thumb_link'); if (!$avatarUrl) { $avatarUrl = null; } JFBCFactory::cache()->store($avatarUrl, 'meetup.avatar.' . $providerUserId); } return $avatarUrl; }
public function getStream($stream) { $user = $this->options->get('user_id'); if (!$user) { return; } $feed = JFBCFactory::cache()->get('twitter.stream.' . $user); if ($feed === false) { $accessToken = JFBCFactory::usermap()->getUserAccessToken($user, 'twitter'); if (!$accessToken) { return; } $params = array(); $params['oauth_token'] = $accessToken->key; $this->provider->client->setToken((array) $accessToken); $path = $this->provider->options->get('api.url') . 'statuses/user_timeline.json'; $feedResponse = $this->provider->client->oauthRequest($path, 'GET', $params); if ($feedResponse->code != 200) { return array(); } $feed = json_decode($feedResponse->body); JFBCFactory::cache()->store($feed, 'twitter.stream.' . $user); } if ($feed) { foreach ($feed as $data) { $post = new JFBConnectPost($this); $tweet = $data->retweeted ? $data->retweeted_status : $data; $post->message = isset($tweet->text) ? $tweet->text : ""; $post->authorScreenName = '@' . $tweet->user->screen_name; $post->authorName = $tweet->user->name; $post->authorImage = $tweet->user->profile_image_url_https; $post->updatedTime = isset($data->created_at) ? $data->created_at : ""; $post->thumbLink = isset($tweet->entities->urls[0]) ? $tweet->entities->urls[0]->expanded_url : ""; $post->link = 'https://twitter.com/' . $tweet->user->screen_name . '/status/' . $data->id_str; $stream->addPost($post); } } }
public function getData() { try { $key = strtolower($this->systemName) . '.' . strtolower($this->provider->systemName); $key .= '.' . strtolower(str_replace(' ', '_', $this->name)) . '.' . md5($this->options->toString()); //add caching capability $this->response = JFBCFactory::cache()->get($key); if ($this->response === false) { $data = $this->query(); if ($data->code == 200) { $this->response = json_decode($data->body, true); if (is_array($this->response)) { $this->response = (object) $this->response; } // Perform the curl Request and get $response JFBCFactory::cache()->store($this->response, $key); } } } catch (Exception $e) { if (JFBCFactory::config()->get('facebook_display_errors')) { JFBCFactory::log($e->getMessage()); } } }
function getSocialAvatar($registerType, $profileLink) { $html = ""; if ($this->params->get('enableProfilePic') == 'social' && $this->isJFBConnectInstalled) { $userId = $this->user->get('id'); $html = JFBCFactory::cache()->get('sclogin.avatar.' . $userId); if ($html === false) { foreach ($this->providers as $provider) { $html = $this->getProviderAvatar($provider, $this->user); if ($html != "") { JFBCFactory::cache()->store($html, 'sclogin.avatar.' . $userId); break; } } } } else { $html = $this->getJoomlaAvatar($registerType, $profileLink, $this->user); } if ($html != "") { $html = '<div id="scprofile-pic">' . $html . '</div>'; } return $html; }
function getAvatarUrl($providerUserId, $nullForDefault = false, $params = null) { if (!$params) { $params = new JRegistry(); } $width = $params->get('width', 300); $nullString = $nullForDefault ? 'null' : 'notnull'; $avatarUrl = JFBCFactory::cache()->get('google.avatar.' . $nullString . '.' . $providerUserId . '.' . $width); if ($avatarUrl === false) { $profile = $this->fetchProfile($providerUserId, 'image'); $avatarUrl = $profile->get('image.url', null); // Check for default image if ($avatarUrl) { if ($nullForDefault) { $http = new JHttp(); $avatar = $http->get($avatarUrl); if ($avatar->code == 200 && $avatar->headers['Content-Length'] == 946) { $avatarUrl = null; } } if ($avatarUrl) { $avatarUrl = str_replace("?sz=50", "?sz=" . $width, $avatarUrl); } // get a suitably large image to be resized JFBCFactory::cache()->store($avatarUrl, 'google.avatar.' . $nullString . '.' . $providerUserId . '.' . $width); } } return $avatarUrl; }
function getAvatarUrl($providerId, $nullForDefault = true, $params = null) { $nullString = $nullForDefault ? 'null' : 'notnull'; $avatarUrl = JFBCFactory::cache()->get('vk.avatar.' . $nullString . '.' . $providerId); if ($avatarUrl === false) { $data = $this->fetchProfile($providerId, "photo_big"); $avatarUrl = $data->get('photo_big', null); if ($nullForDefault && (!$avatarUrl || strpos($avatarUrl, 'vk.com/images/camera_'))) { $avatarUrl = null; } JFBCFactory::cache()->store($avatarUrl, 'vk.avatar.' . $nullString . '.' . $providerId); } return $avatarUrl; }
private function buildListOfTagsToReplace() { $tagsToReplace = JFBCFactory::cache()->get('system.alleasytags'); if ($tagsToReplace === false) { $providers = JFBCFactory::getAllWidgetProviderNames(); $tagsToReplace = array(); foreach ($providers as $provider) { $widgets = JFBCFactory::getAllWidgets($provider); foreach ($widgets as $widget) { $tagsToReplace[strtolower($widget->tagName)] = array('provider' => $provider, 'widget' => $widget->systemName); } } //Manually add SCLinkedinLogin, since JLinkedLogin is the actual tag $tagsToReplace['sclinkedinlogin'] = array('provider' => 'linkedin', 'widget' => 'login'); //Tags like JFBCShare and JFBCRecommendations need to come up after JFBCShareDialog and JFBCRecommendationsBar $tagsToReplace = array_reverse($tagsToReplace); JFBCFactory::cache()->store($tagsToReplace, 'system.alleasytags'); } $this->tagsToReplace = $tagsToReplace; }
public function getStream($stream) { $user = $this->options->get('user_id'); if (!$user) { return; } $companyId = $this->options->get('company_id'); $feed = JFBCFactory::cache()->get('linkedin.stream.' . $companyId); if ($feed === false) { $access_token = JFBCFactory::usermap()->getUserAccessToken($user, 'linkedin'); if (!is_object($access_token) || $access_token->created + $access_token->expires_in < time()) { return; } $url = 'https://api.linkedin.com/v1/companies/' . $companyId . '/updates'; $this->provider->client->setToken((array) $access_token); try { $feedResponse = $this->provider->client->query($url, json_encode(array()), array(), 'get'); if ($feedResponse->code != 200) { return; } $feed = json_decode($feedResponse->body); JFBCFactory::cache()->store($feed, 'linkedin.stream.' . $companyId); } catch (Exception $e) { if (JFBCFactory::config()->get('facebook_display_errors')) { JFBCFactory::log('LinkedIn Stream: ' . $e->getMessage(), 'error'); } return; } } if (isset($feed->values) && $feed->values) { foreach ($feed->values as $data) { $post = new JFBConnectPost(); $post->authorScreenName = $data->updateContent->company->name; if (isset($data->updateContent->companyJobUpdate)) { $post->type = 'job-posting'; $post->message = isset($data->updateContent->companyJobUpdate->job->description) ? $data->updateContent->companyJobUpdate->job->description : ""; $post->jobLocation = isset($data->updateContent->companyJobUpdate->job->locationDescription) ? $data->updateContent->companyJobUpdate->job->locationDescription : ""; $post->jobPosition = isset($data->updateContent->companyJobUpdate->job->position->title) ? $data->updateContent->companyJobUpdate->job->position->title : ""; $post->link = isset($data->updateContent->companyJobUpdate->job->siteJobRequest->url) ? $data->updateContent->companyJobUpdate->job->siteJobRequest->url : ""; } elseif (isset($data->updateContent->companyStatusUpdate)) { $post->type = 'status-update'; $post->message = isset($data->updateContent->companyStatusUpdate->share->comment) ? $data->updateContent->companyStatusUpdate->share->comment : ""; $post->thumbLink = isset($data->updateContent->companyStatusUpdate->share->content->submittedUrl) ? $data->updateContent->companyStatusUpdate->share->content->submittedUrl : ""; $post->thumbPicture = isset($data->updateContent->companyStatusUpdate->share->content->submittedImageUrl) ? $data->updateContent->companyStatusUpdate->share->content->submittedImageUrl : ""; $post->thumbDescription = isset($data->updateContent->companyStatusUpdate->share->content->description) ? $data->updateContent->companyStatusUpdate->share->content->description : ""; $post->thumbCaption = isset($data->updateContent->companyStatusUpdate->share->content->eyebrowUrl) ? $data->updateContent->companyStatusUpdate->share->content->eyebrowUrl : ""; $post->thumbTitle = isset($data->updateContent->companyStatusUpdate->share->content->title) ? $data->updateContent->companyStatusUpdate->share->content->title : ""; $post->link = ''; //check if we have the correct update-key format // update key format will be UPDATE-c[company_id]-[topic_id].. ex. UPDATE-c1441-5965553136775999488 if (isset($data->updateKey)) { $keyA = explode('-', $data->updateKey); if (strpos($data->updateKey, 'UPDATE') !== false && count($keyA) == 3) { $post->link = 'https://www.linkedin.com/nhome/updates?topic=' . $keyA[2]; } } } if (isset($data->timestamp)) { $timestamp = intval($data->timestamp / 1000); $post->updatedTime = gmdate($stream->options->get('datetime_format'), $timestamp); } else { $post->updatedTime = ""; } $stream->addPost($post); } } }
function getAvatarUrl($providerId, $nullForDefault = true, $params = null) { $avatarUrl = JFBCFactory::cache()->get('linkedin.avatar.' . $providerId); if ($avatarUrl === false) { $data = $this->fetchProfile($providerId, 'picture-urls::(original)'); $avatarUrl = $data->get('picture-urls.values.0'); if ($avatarUrl == "") { $avatarUrl = null; } JFBCFactory::cache()->store($avatarUrl, 'linkedin.avatar.' . $providerId); } return $avatarUrl; }
function getProfileUrl($fbUserId) { $profileUrl = JFBCFactory::cache()->get('facebook.link.' . '.' . $fbUserId); if ($profileUrl === false) { $profileData = JFBCFactory::provider('facebook')->api('/' . $fbUserId . '?fields=link'); if (is_array($profileData) && array_key_exists('link', $profileData)) { $profileUrl = $profileData['link']; } JFBCFactory::cache()->store($profileUrl, 'facebook.link.' . '.' . $fbUserId); } return $profileUrl; }