Skip to content

Commit

Permalink
Some changes were missing
Browse files Browse the repository at this point in the history
  • Loading branch information
TheoChevalier committed Oct 19, 2014
1 parent 6d0cde5 commit 845cb8e
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 29 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
config/
config/config.ini
vendor/
composer.lock
composer.phar
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,15 @@ Le site sera composé de :
=========================
- 1 blog wordpress
- 1 page d'accueil customisé avec récupération du contenu des différentes réseaux sociaux et blogs de la communauté


Dépendances techniques :
=========================

Composer (Dependency Manager for PHP, http://getcomposer.org/)


Installation :

Lancer |./composer.phar update|
Configurer les identifiants FB/Twitter dans config/config.ini
30 changes: 19 additions & 11 deletions classes/TileFacebook.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,31 @@
use Facebook\FacebookRequest;

class TileFacebook {
private $_fb_pageID;
private $_fb_appID;
private $_fb_appsecret;

/**
* Lit le fichier de configuration et s'authentifie auprès de Twitter
* @param $_pathToConf Chemin vers le fichier de configuration .ini
* @throws Exception Renvoie une exception si le fichier n'est pas trouvé ou n'est pas lisible
* Reads config file
* @param $_pathToConf Path to config.ini file
* @throws Exception Triggers an Exception when the file can't be read or can't be found.
*/
public function __construct($pathToConf) {
if (! file_exists($pathToConf) || ! is_readable($pathToConf)) {
throw new Exception('TileFacebook.php : config file not found');
} else {
$config = parse_ini_file($pathToConf, false);

$this->_fb_appID = $config['fb_appID'];
$this->_fb_appsecret = $config['fb_appsecret'];
$this->_fb_pageID = $config['fb_pageID'];
$this->_fb_appID = $config['fb_appID'];
$this->_fb_appsecret = $config['fb_appsecret'];
}
}

/**
* Returns the latest status posted by the FB account/page identified by credentials found in config.ini
* @return String containing the latest status
*/
public function getLatestStatus() {
FacebookSession::setDefaultApplication($this->_fb_appID, $this->_fb_appsecret);

Expand All @@ -34,21 +40,23 @@ public function getLatestStatus() {
$request = new FacebookRequest(
$session,
'GET',
'/571893379557863/posts?limit=10'
'/' . $this->_fb_pageID . '/posts?limit=10'
);

$response = $request->execute();
$graphObject = $response->getGraphObject()->asArray();

// Keep parsing graphObject activity until an actual post is found.
// Currently, activity includes page comments, and they don't have a 'message' field.
$i = 0;
while (empty($fb_status) || $i >= 9) {
try {
$fb_status = $graphObject['data'][$i]->message;
} catch (Exception $e) {}
if (isset($graphObject['data'][$i]->message)) {
try {
$fb_status = $graphObject['data'][$i]->message;
} catch (Exception $e) {}
}
$i++;
}
return $fb_status;
}
}

?>
6 changes: 4 additions & 2 deletions config/config.ini.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Rename this file to config.ini then set you FB and Twitter access data.

fb_appID =
fb_appID =

fb_appsecret =
fb_pageID =

fb_appsecret =
11 changes: 11 additions & 0 deletions css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@
padding-top: 60px;
}

#promo-8 {
background: url(../media/img/fb.png) no-repeat 20px 20px,
#5E6BA1;
}

#promo-8 p {
padding: 5px 5px 0 70px;
overflow: hidden;
word-wrap: break-word;
}

#promo-9 {
background: url(../media/img/logo-mdn.svg) no-repeat top center,
url(../media/img/blueprint.png) repeat,
Expand Down
23 changes: 8 additions & 15 deletions includes/body.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@
</span>
</a>
</li>
</ul>
</div>
<a class="fxos-link" href="https://www.mozilla.org/fr/firefox/desktop/">En savoir plus</a>
</ul>
</div>
</div>
</li>
<li id="promo-6" class="item promo-large-landscape webmaker" tabindex="0" data-name="Teach the Web">
Expand All @@ -63,17 +62,17 @@
</div>
</a>
</li>
<li id="promo-8" class="item promo-small-landscape appmaker" data-name="Build an app in seconds">
<a class="panel-link" rel="external" href="https://webmaker.org/appmaker">
<h2>Facebook</h2>
<li id="promo-8" class="item promo-small-landscape appmaker" data-name="Dernier statut Facebook">
<a class="panel-link" rel="external" href="https://www.facebook.com/firefoxosfr">
<p><?=$fb_status?></p>
</a>
</li>
<li id="promo-9" class="item promo-small-landscape volunteer" data-name="Volunteer with Mozilla">
<li id="promo-9" class="item promo-small-landscape volunteer" data-name="Firefox OS pour les développeurs">
<a class="panel-link" href="https://developer.mozilla.org/fr/Firefox_OS">
<h2>Firefox&nbsp;OS pour les développeurs</h2>
</a>
</li>
<li id="promo-10" class="item promo-large-portrait firefox-desktop" tabindex="0" data-name="Try the best Firefox yet">
<li id="promo-10" class="item promo-large-portrait firefox-desktop" tabindex="0" data-name="La parole est aux mozilliens">
<img class="primary go" src="media/img/foxprimez-vous.png" alt="Le renard s’exprime publiquement">
<h2 class="primary go">Foxprimez-vous</h2>
<a class="panel-link" href="http://www.mozfr.org">
Expand All @@ -84,13 +83,7 @@
</a>
</li>
<li id="promo-11" class="item promo-large-landscape support" tabindex="0" data-name="Help Mozilla users">
<h2 class="primary go">Chaîne Youtube</h2>
<a class="panel-link" rel="external" href="https://support.mozilla.org/get-involved">
<div class="secondary">
<h3>Lorem ipsum.</h3>
<p class="more">Lorem ipsum</p>
</div>
</a>
<div id="player"></div>
</li>
</ul>
</div>
Expand Down
2 changes: 2 additions & 0 deletions includes/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
<link rel="stylesheet" media="screen,projection,tv" href="css/main.css">
<link rel="shortcut icon" href="https://mozorg.cdn.mozilla.net/media/img/favicon.ico">
<script src="media/js/site-min.js"></script>
<!-- Async player loading -->
<script src="media/js/player.js"></script>
</head>
<body id="home" class="html-ltr lang-fr">
Expand Down
8 changes: 8 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
<?php

require_once 'vendor/autoload.php';
require_once("classes/TileFacebook.php");

$fb = new TileFacebook('config/config.ini');
$fb_status = $fb->getLatestStatus();



include('includes/header.php');
include('includes/body.php');
include('includes/footer.php');

0 comments on commit 845cb8e

Please sign in to comment.