private function getSocialsData($website_url = '', $force_refresh_cache = false) { $cache_life_time = 60 * 10; // in seconds $the_db_cache = $this->the_plugin->get_theoption("psp_dashboard_social_statistics"); // check if cache NOT expires if (isset($the_db_cache['_cache_date']) && time() <= $the_db_cache['_cache_date'] + $cache_life_time && $force_refresh_cache == false) { return $the_db_cache; } $db_cache = array(); $db_cache['_cache_date'] = time(); // Alexa rank $apiQuery = 'http://data.alexa.com/data?cli=10&dat=snbamz&url=' . $website_url; $alexa_data = $this->getRemote($apiQuery, false); $xml = simplexml_load_string($alexa_data); $json = json_encode($xml); $array = json_decode($json, TRUE); // Facebook $fql = "SELECT url, normalized_url, share_count, like_count, comment_count, "; $fql .= "total_count, commentsbox_count, comments_fbid, click_count FROM "; $fql .= "link_stat WHERE url = '{$website_url}'"; $apiQuery = "https://api.facebook.com/method/fql.query?format=json&query=" . urlencode($fql); $fb_data = $this->getRemote($apiQuery); $fb_data = $fb_data[0]; // Twitter $apiQuery = "http://urls.api.twitter.com/1/urls/count.json?url=" . $website_url; $tw_data = $this->getRemote($apiQuery); // LinkedIn $apiQuery = "http://www.linkedin.com/countserv/count/share?format=json&url=" . $website_url; $ln_data = $this->getRemote($apiQuery); // Pinterest $apiQuery = "http://api.pinterest.com/v1/urls/count.json?callback=receiveCount&url=" . $website_url; $pn_data = $this->getRemote($apiQuery); // StumbledUpon $apiQuery = "http://www.stumbleupon.com/services/1.01/badge.getinfo?url=" . $website_url; $st_data = $this->getRemote($apiQuery); // Delicious $apiQuery = "http://feeds.delicious.com/v2/json/urlinfo/data?url=" . $website_url; $de_data = $this->getRemote($apiQuery); $de_data = $de_data[0]; // Google Plus $apiQuery = "https://plusone.google.com/_/+1/fastbutton?bsv&size=tall&hl=it&url=" . $website_url; $go_data = $this->getRemote($apiQuery, false); require_once $this->the_plugin->cfg['paths']['scripts_dir_path'] . '/php-query/php-query.php'; $html = pspphpQuery::newDocumentHTML($go_data); $go_data = $html->find("#aggregateCount")->text(); // store for feature cache $db_cache['alexa'] = $array['SD'][1]['POPULARITY']["@attributes"]['TEXT']; $db_cache['facebook'] = array('share_count' => $fb_data['share_count'], 'like_count' => $fb_data['like_count'], 'comment_count' => $fb_data['comment_count'], 'click_count' => $fb_data['click_count']); $db_cache['google'] = $go_data; $db_cache['twitter'] = $tw_data['count']; $db_cache['linkedin'] = $ln_data['count']; $db_cache['pinterest'] = $pn_data['count']; $db_cache['stumbleupon'] = $st_data['result']['views']; $db_cache['delicious'] = $de_data['total_posts']; // create a DB cache of this $this->the_plugin->save_theoption('psp_dashboard_social_statistics', $db_cache); return $db_cache; }
public function get_page_social_stats($postID, $website_url = '') { /* $__ = array( 'http://mashable.com', 'http://facebook.com', 'http://stiumuzica.ro', 'http://themeforest.net', 'http://codecanyon.net' ); shuffle($__); $website_url = $__[0];*/ $cache_life_time = 240 * 10; // in seconds $the_db_cache = get_post_meta($postID, '_psp_social_stats', true); // check if cache NOT expires if (isset($the_db_cache['_cache_date']) && time() <= $the_db_cache['_cache_date'] + $cache_life_time) { return $the_db_cache; } $db_cache = array(); $db_cache['_cache_date'] = time(); // Facebook $fql = "SELECT url, normalized_url, share_count, like_count, comment_count, "; $fql .= "total_count, commentsbox_count, comments_fbid, click_count FROM "; $fql .= "link_stat WHERE url = '{$website_url}'"; $apiQuery = "https://api.facebook.com/method/fql.query?format=json&query=" . urlencode($fql); $fb_data = $this->getRemote($apiQuery); $fb_data = $fb_data[0]; // Twitter $apiQuery = "http://urls.api.twitter.com/1/urls/count.json?url=" . $website_url; $tw_data = $this->getRemote($apiQuery); // LinkedIn $apiQuery = "http://www.linkedin.com/countserv/count/share?format=json&url=" . $website_url; $ln_data = $this->getRemote($apiQuery); // Pinterest $apiQuery = "http://api.pinterest.com/v1/urls/count.json?callback=receiveCount&url=" . $website_url; $pn_data = $this->getRemote($apiQuery); // StumbledUpon $apiQuery = "http://www.stumbleupon.com/services/1.01/badge.getinfo?url=" . $website_url; $st_data = $this->getRemote($apiQuery); // Delicious $apiQuery = "http://feeds.delicious.com/v2/json/urlinfo/data?url=" . $website_url; $de_data = $this->getRemote($apiQuery); $de_data = $de_data[0]; // Google Plus $apiQuery = "https://plusone.google.com/_/+1/fastbutton?bsv&size=tall&hl=it&url=" . $website_url; $go_data = $this->getRemote($apiQuery, false); require_once $this->the_plugin->cfg['paths']['scripts_dir_path'] . '/php-query/php-query.php'; $html = pspphpQuery::newDocumentHTML($go_data); $go_data = $html->find("#aggregateCount")->text(); $db_cache['facebook'] = array('share_count' => $fb_data['share_count'], 'like_count' => $fb_data['like_count'], 'comment_count' => $fb_data['comment_count'], 'click_count' => $fb_data['click_count']); $db_cache['google'] = $go_data; $db_cache['twitter'] = $tw_data['count']; $db_cache['linkedin'] = $ln_data['count']; $db_cache['pinterest'] = $pn_data['count']; $db_cache['stumbleupon'] = $st_data['result']['views']; $db_cache['delicious'] = $de_data['total_posts']; // create a DB cache of this update_post_meta($postID, '_psp_social_stats', $db_cache); return $db_cache; }
/** * Check if the keyword is contained in the HTML italic tag. * * @param string $page_content * @param string $focus_kw * @return array $results The results array. */ function score_html_italic($page_content, $focus_kw) { $html = pspphpQuery::newDocumentHTML($page_content); $msgs = array('missing' => __("Bad, your content has no italic elements.", $this->the_plugin->localizationName), 'less' => __("Bad, your content has %d italic elements and none of this contains your most important keywords.", $this->the_plugin->localizationName), 'good' => __("Great, your content has %d italic elements and at least 1 contains your most important keywords.", $this->the_plugin->localizationName)); $total_italics = $html->find('em,i')->size(); if ($total_italics > 0) { if (preg_match('/' . preg_quote($focus_kw, '/') . '/i', $html->find('em,i')->text()) == true) { return array('score' => 1, 'msg' => sprintf($msgs['good'], $total_italics)); } else { return array('score' => 0, 'msg' => sprintf($msgs['less'], $total_italics)); } } else { return array('score' => 0, 'msg' => sprintf($msgs['missing'], $total_italics)); } }