コード例 #1
0
ファイル: ConfigController.php プロジェクト: jsehersan/social
 public function getConfigChannel($id)
 {
     session_start();
     $ch = Helper::getChannel($id);
     // FACEBOOK
     if ($ch->type == 'f') {
         if (!$ch) {
             return "Canal no encontrado";
         }
         if (Input::get('code')) {
             FacebookSession::setDefaultApplication($ch->getParam('APP_ID'), $ch->getParam('APP_SECRET'));
             $helper = new FacebookRedirectLoginHelper(URL::to('social/config/channel/' . $id));
             $session = $helper->getSessionFromRedirect();
             if ($session->validate()) {
                 $request = new FacebookRequest($session, 'GET', '/me/accounts?fields=name,access_token,perms');
                 $pageList = $request->execute()->getGraphObject()->asArray();
                 if ($ch->getParam('PAGE_ID')) {
                     //Comprobamos que la pagina que hemos introducido esta entre las que administra el usuario
                     $page = Facebook::checkIdPage($ch->getParam('PAGE_ID'), $pageList['data']);
                     if ($page) {
                         $ch->setParam('TOKEN', $page->access_token);
                         $ch->setParam('PAGE_NAME', $page->name);
                         return Redirect::to('social/config/channel/' . $id)->with('message', 'Canal configurado con exito , Página ' . $page->name);
                     }
                 }
                 return Redirect::to('social/config/channel/' . $id)->with('error', 'Debe introducir el id de la pagina con la cuel quiere publicar');
             }
         }
         if ($ch->getParam('TOKEN')) {
             // $ch->getTokenInfo();
         }
     }
     // !!
     // TWITTER
     if ($ch->type == 't') {
         //          try{
         //
         //           // $res = file_get_contents('http://tinyurl.com/api-create.php?url=http://stackoverflow.com/questions/22355828/doing-http-requests-from-laravel-to-an-external-api');
         //            //$uploaded_media = Social::Twitter()->uploadMedia(['media' => File::get(public_path('front/images/vilca_logo4.png'))]);
         //            //$res=Social::Twitter()->postTweet(['status' => ' defg  ,jh efg  ,jh  defg  ,jh  defg   defg  ,jh  defg  ,jh  defg  ,j fin '.$res, 'media_ids' => $uploaded_media->media_id_string]);;
         //          //  var_dump( Social::Twitter()->getUserTimeline(['screen_name' => 'thujohn', 'count' => 1, 'format' => 'json'])
         //          );
         //          }catch (\Exception $e){
         //
         //              return Redirect::back()->with('error',$e->getMessage());
         //          }
         // $cfg_tw=Config::get('social.twitter');
     }
     $tmp = array('extends' => Config::get('social::social.tmp.admin', 'layout.base'), 'section_main' => Config::get('social::social.tmp.section_main', 'main'));
     $header_title = array('clase' => 'fa fa-share-alt', 'titulo' => 'Social <small>Config::' . $ch->description . '</small>');
     return View::make('social::configChannel', compact('ch', 'tmp', 'header_title'));
 }