Example #1
0
 public static function getChannel($id)
 {
     if ($ty = Channel::find($id)) {
         switch ($ty->type) {
             case 'f':
                 $ch = Facebook::find($id);
                 if ($ch) {
                     $ch->setSession();
                     return $ch;
                 }
                 return false;
                 break;
             case 't':
                 $ch = Twitter::find($id);
                 if ($ch) {
                     return $ch;
                 }
                 return false;
                 break;
             default:
                 return false;
                 break;
         }
     }
     return false;
 }
Example #2
0
 public function ajfb_ValidApp()
 {
     session_start();
     $id_app = Input::get('id_app');
     $secret_app = Input::get('secret_app');
     $id_ch = Input::get('id_ch');
     $page_id = Input::get('page_id');
     try {
         FacebookSession::setDefaultApplication($id_app, $secret_app);
         $helper = new FacebookRedirectLoginHelper(URL::to('social/config/channel/' . $id_ch));
         $params = array('scope' => 'manage_pages', 'publish_actions', 'publish_stream', 'publish_pages');
         $url = $helper->getLoginUrl($params);
         $chDB = Facebook::find($id_ch);
         $chDB->setParam('APP_ID', $id_app);
         $chDB->setParam('APP_SECRET', $secret_app);
         $chDB->setParam('PAGE_ID', $page_id);
         $ch_status = $chDB->validate();
         return Response::json(array('status' => true, 'url' => $url, 'ch_status' => $ch_status));
     } catch (FacebookSDKException $ex) {
         return Response::json(array('status' => false, 'error' => $ex));
     }
     // return Response::json($helper->getLoginUrl());
 }