]> git.immae.eu Git - github/wallabag/wallabag.git/blob - src/Wallabag/ImportBundle/Controller/PocketController.php
service call
[github/wallabag/wallabag.git] / src / Wallabag / ImportBundle / Controller / PocketController.php
1 <?php
2
3 namespace Wallabag\ImportBundle\Controller;
4
5 use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6 use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
7 use Wallabag\ImportBundle\Import\PocketImport;
8
9 class PocketController extends Controller
10 {
11 /**
12 * @Route("/import", name="import")
13 */
14 public function importAction()
15 {
16 return $this->render('WallabagImportBundle:Pocket:index.html.twig', array());
17 }
18
19 /**
20 * @Route("/auth-pocket", name="authpocket")
21 */
22 public function authAction()
23 {
24 $pocket = $this->get('wallabag_import.import.pocket_import');
25 $authUrl = $pocket->oAuthRequest($this->generateUrl('import', array(), true), $this->generateUrl('callbackpocket', array(), true));
26
27 return $this->redirect($authUrl, 301);
28 }
29
30 /**
31 * @Route("/callback-pocket", name="callbackpocket")
32 */
33 public function callbackAction()
34 {
35 $pocket = $this->get('wallabag_import.import.pocket_import');
36 $accessToken = $pocket->oAuthAuthorize();
37 $pocket->import($accessToken);
38
39 return $this->redirect($this->generateUrl('homepage'));
40 }
41 }