Permalink
Browse files

load data from Facebook - dirty version

  • Loading branch information...
chemix committed Jun 12, 2014
1 parent 09420de commit f7abe600372f3e77cb7486dbb393bb85c300e7ed
Showing with 26 additions and 0 deletions.
  1. +26 −0 app/presenters/ImportPresenter.php
@@ -8,6 +8,11 @@
use Nette,
App\Model;
use Facebook\FacebookRequest;
use Facebook\FacebookRequestException;
use Facebook\FacebookSession;
use Tracy\Dumper;
/**
* Import presenter.
@@ -17,7 +22,28 @@ class ImportPresenter extends BasePresenter
public function renderDefault()
{
FacebookSession::setDefaultApplication('YOUR_APP_ID', 'YOUR_APP_SECRET');
$session = FacebookSession::newAppSession();
$data = array();
try {
$request = new FacebookRequest($session, 'GET', '/nettefw/feed');
$response = $request->execute();
$posts = $response->getGraphObject()->asArray();
$data = $posts['data'];
} catch (FacebookRequestException $ex) {
// Session not valid, Graph API returned an exception with the reason.
echo $ex->getMessage();
exit();
} catch (\Exception $ex) {
// Graph API returned info, but it may mismatch the current app or have expired.
echo $ex->getMessage();
exit();
}
Dumper::dump($data);
}
}

0 comments on commit f7abe60

Please sign in to comment.