Ejemplo n.º 1
0
 private function searchAccountInDB($username, $social_network)
 {
     switch ($social_network) {
         case 'facebook':
             $data = FacebookPage::whereUsername($username)->first(['fb_id', 'username', 'name']);
             break;
         case 'twitter':
             $data = TwitterProfile::whereScreenName($username)->first(['screen_name', 'name', 'picture']);
             break;
         case 'instagram':
             $data = InstagramProfile::whereUsername($username)->first(['username', 'name', 'picture']);
             break;
         default:
             return 'Invalid method';
             break;
     }
     if ($data) {
         $page['username'] = strtolower(isset($data['username']) ? $data['username'] : $data['screen_name']);
         $page['name'] = !empty($data['name']) ? $data['name'] : $page['username'];
         $page['picture'] = $social_network == 'facebook' ? 'http://graph.facebook.com/' . $data['fb_id'] . '/picture?height=200&type=normal&width=200' : str_replace('_normal.', '_200x200.', $data['picture']);
         return $page;
     } else {
         return NULL;
     }
 }
Ejemplo n.º 2
0
 public function getRankingPageGrow($idiom)
 {
     $where = ucfirst($idiom);
     $var_cache = 'rankingGrowLikes' . $where;
     if (!Cache::has($var_cache)) {
         $ranking = FacebookPage::take(4)->orderBy('likes_grow_30', 'DESC');
         switch ($where) {
             case 'All':
                 $ranking->whereParent(0)->orWhereRaw('id_page = parent');
                 break;
             case 'Es':
                 $ranking->whereIdiom('es')->whereParent(0)->orWhereRaw('id_page = parent');
                 break;
                 /*case 'It':
                   $ranking->whereIdiom('it')->whereParent(0)->orWhereRaw('id_page = parent');
                   break;*/
             /*case 'It':
               $ranking->whereIdiom('it')->whereParent(0)->orWhereRaw('id_page = parent');
               break;*/
             default:
                 return 'Invalid method';
         }
         $ranking = $ranking->get(['fb_id', 'username', 'name', 'likes', 'likes_grow_30']);
         $pages = array();
         foreach ($ranking as $key => $value) {
             $cache = NULL;
             $cache['username'] = strtolower($value['username']);
             $cache['name'] = $value['name'];
             $cache['picture'] = 'https://graph.facebook.com/' . $value['fb_id'] . '/picture?type=large';
             $cache['percent'] = 0;
             if ($value['likes'] - $value['likes_grow_30'] > 0) {
                 $cache['percent'] = $this->owlooFormatPorcent($value['likes_grow_30'], $value['likes'] - $value['likes_grow_30']);
             }
             $cache['grow_30'] = $this->owloo_number_format($value['likes_grow_30']);
             $pages[] = $cache;
         }
         Cache::put($var_cache, $pages, 1440);
     }
     return Cache::get($var_cache);
 }
Ejemplo n.º 3
0
 public function getLastPageAdded($idiom, $limit = 4)
 {
     $where = strtolower($idiom);
     $var_cache = 'lastFacebookPageAdded' . ucfirst($where) . $limit;
     if (!Cache::has($var_cache)) {
         $ranking = FacebookPage::take($limit)->orderBy('id_page', 'DESC');
         switch ($where) {
             case 'all':
                 $ranking->whereParent(0)->orWhereRaw('id_page = parent');
                 break;
             default:
                 $country_idiom = FacebookCountry::whereIdiom($where)->first();
                 if ($country_idiom) {
                     $ranking->whereIdiom($where)->where(function ($query) {
                         $query->whereParent(0)->orWhereRaw('id_page = parent');
                     });
                 } else {
                     return 'Invalid method';
                 }
         }
         $ranking = $ranking->get(['fb_id', 'username', 'name']);
         $pages = array();
         foreach ($ranking as $key => $value) {
             $cache = NULL;
             $cache['username'] = strtolower($value['username']);
             $cache['name'] = $value['name'];
             $cache['picture'] = 'https://graph.facebook.com/' . $value['fb_id'] . '/picture?type=large';
             $pages[] = $cache;
         }
         Cache::put($var_cache, $pages, 1440);
     }
     return Cache::get($var_cache);
 }
Ejemplo n.º 4
0
 public function getTotalUsers()
 {
     return FacebookPage::whereActive('1')->count();
 }
Ejemplo n.º 5
0
<?php

error_reporting(E_ALL);
ini_set('display_errors', true);
require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/FacebookPage.php';
require_once __DIR__ . '/config.inc.php';
$limit = 1;
$id = '245916628859249';
$token = 'CAACWiAlh00MBAK5CZCZBfCx08JQEkZCcu9BBL2rXQH1o9IUzql4tJfy4bTp1lsjT4MjFFwaJ2Q6sdWZBkBM9NEFoLHrM3UmGcjbggmcHQeoZCYx5WkMaQpGJmKrGmHik3nbiuJE2RnJEtWDZC9snMkFFU0IcZBDSCORITtyl4yo6ZA7utUHBw74b';
$page = new FacebookPage($config, $pageConfig);
$posts = $page->getPosts(10);
?>
<!DOCTYPE html>
<html id="top">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>Facebook Page Posts example</title>
  <meta name="description" content="Mode, kleding, jurken, fashion, online shop ✔ Geen retourkosten ✔ Veilig betalen ✔ Een outfit voor elk moment!" />
  <meta name="keywords" content="" />
  <meta name="robots" content="INDEX,FOLLOW" />
  <link rel="stylesheet" type="text/css" href="styles.css" media="all" />
  <meta name="viewport" content="initial-scale=1.0, width=device-width" />
</head>
<body >
  <div class="wrapper">

    <ol class="fb-posts">
      <?php 
foreach ($posts as $post) {
    ?>
Ejemplo n.º 6
0
 public function getRankingPageDev($where, $category, $page = 1)
 {
     $where = ucfirst($where);
     if (!Cache::has('rankingLikes' . $where . 'PageCat' . $category . '_' . ($page - 1) * 20)) {
         if ($where != 'World' && $where != 'Hispanic') {
             $ranking = FacebookPageLocalFans::take(20)->skip(($page - 1) * 20)->orderBy('likes_local_fans', 'DESC')->orderBy('likes', 'DESC');
         } else {
             $ranking = FacebookPage::take(20)->skip(($page - 1) * 20)->orderBy('likes', 'DESC')->orderBy('talking_about', 'DESC');
         }
         switch ($where) {
             case 'World':
                 $ranking->whereParent(0);
                 break;
             case 'Hispanic':
                 $ranking->whereIdiom('es')->whereParent(0);
                 break;
             default:
                 if (FacebookPage::whereCode(strtolower($where))) {
                     $ranking->where('country_code', strtoupper($where));
                 } else {
                     return 'Invalid method';
                 }
         }
         if ($category != 'all' && is_numeric($category)) {
             $ranking->where('Category_id', $category);
         }
         if ($where != 'World' && $where != 'Hispanic') {
             $ranking = $ranking->get(['fb_id', 'username', 'name', 'is_verified', 'likes', 'likes_grow_7', 'talking_about', 'likes_local_fans']);
         } else {
             $ranking = $ranking->get(['fb_id', 'username', 'name', 'is_verified', 'likes', 'likes_grow_7', 'talking_about', 'country_code', 'first_country_code']);
         }
         foreach ($ranking as $key => $value) {
             $cache = NULL;
             $cache['position'] = ($page - 1) * 20 + $key + 1;
             $cache['username'] = strtolower($value['username']);
             $cache['name'] = $value['name'];
             $cache['picture'] = 'http://graph.facebook.com/' . $value['fb_id'] . '/picture?height=50&type=normal&width=50';
             $cache['is_verified'] = $value['is_verified'];
             $cache['likes'] = $this->owloo_number_format($value['likes']);
             $cache['grow_7'] = $value['likes_grow_7'];
             $cache['pta'] = 0;
             if ($value['likes'] > 0) {
                 $cache['pta'] = $this->owlooFormatPorcent($value['talking_about'], $value['likes']);
             }
             if ($where != 'World' && $where != 'Hispanic') {
                 $cache['likes_local_fans'] = $this->owloo_number_format($value['likes_local_fans']);
             } else {
                 $cache['country'] = strtolower(!empty($value['country_code']) ? $value['country_code'] : $value['first_country_code']);
             }
             $var = 'rankingLikes' . $where . 'PageCat' . $category . '_' . (($page - 1) * 20 + $key);
             Cache::put($var, $cache, 1440);
         }
     }
     $from = ($page - 1) * 20;
     $to = $page * 20 - 1;
     $foo = array();
     for ($from; $from <= $to; $from++) {
         $var = 'rankingLikes' . $where . 'PageCat' . $category . '_' . $from;
         $foo[$from] = Cache::get($var);
     }
     return $foo;
 }
Ejemplo n.º 7
0
/**
 * Return facebook posts.
 *
 * @todo: Make posts clickable
 *
 */
error_reporting(E_ALL);
ini_set('display_errors', true);
require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/FacebookPage.php';
require_once __DIR__ . '/config.inc.php';
$limit = 1;
$id = '245916628859249';
$token = 'CAACWiAlh00MBAK5CZCZBfCx08JQEkZCcu9BBL2rXQH1o9IUzql4tJfy4bTp1lsjT4MjFFwaJ2Q6sdWZBkBM9NEFoLHrM3UmGcjbggmcHQeoZCYx5WkMaQpGJmKrGmHik3nbiuJE2RnJEtWDZC9snMkFFU0IcZBDSCORITtyl4yo6ZA7utUHBw74b';
$page = new FacebookPage($config, $pageConfig);
$posts = $page->getPosts(getCount());
$content = '<div class="fb-content"><h2>Boerhaavegroep op Facebook</h2><div id="fb-wrap">';
$content .= '<ol id="fb-carousel" class="fb-posts group">';
foreach ($posts as $post) {
    if (empty($post['media']['photos'])) {
        continue;
    }
    $content .= '<li>';
    $content .= '<a href="' . $post['url'] . '" target="_blank">';
    $content .= '<p class="message">' . $post['message'] . '</p>';
    $content .= '<div class="image">';
    $content .= '<img src="' . $post['media']['main_image']['src'] . '" height="320">';
    if (count($post['media']['photos']) > 1) {
        $content .= '<div class="photos">' . count($post['media']['photos']) . '</div>';
    }