2012-05-01 17 views
0

可能性の重複:
Submission of form should be done when on user loginfacebookでログイン後、同じページにリダイレクト応じ

は以下は、私がスクリプトをしようとされた私のコードですfacebookに投稿するためのチェックボックスがチェックされている場合、最初にユーザはfacebookにログインしているかどうかチェックされますが、そうでなければfacebookページにリダイレクトされ、ログインして同じページにリダイレクトされます。 私はmagentoに取り組んでいますし、フェイスブックに投稿するchecboxをチェックすると、facebookに私をリダイレクトして、そこに私をログインさせますが、私を成功裏にリダイレクトせず、無効なフォームデータのエラーを返しません どうかどうぞ私はしようとしているタスクを達成するのに役立つ次のコードを変更できますか?

function myfunction() 
    { 
    $myformData = $this->getRequest()->getPost('myform'); 
     $fbpost=$myformData['fbpost']; 
$app_id = "APP_ID"; 
      $app_secret = "APP_SECRET"; 
      $facebook = new Facebook(array(
      'appId' => $app_id, 
      'secret' => $app_secret, 
      'cookie' => true, 
      'fileUpload' => true, 
      )); //making object for facebook connectivity 

$user = $facebook->getUser(); 
if($user==0 && isset($fbpost)) // checking if user is login to facebook or not 
{ 
header("Location:{$facebook->getLoginUrl(array('scope' => 'photo_upload,publish_stream,user_photos,manage_pages'))}"); //redirecting to facebook 

} 
else 
{ 


      // $con = $this->_getConnection(); 
    //  Mage::helper('Octopus/') 
      $store = Mage::app()->getStore();$userId = $store->getName(); 
       $db = Mage::getSingleton('core/resource')->getConnection(core_write); 

      $myformData = $this->getRequest()->getPost('myform'); 
      $fbpost=$myformData['fbpost']; 
      if(isset($fbpost)) 
      { 
       echo Mage::helper('function')->test(); 


      } 
       $couponId = $myformData['coupon_id']; 
       $coupontype=$myformData['coupon_type']; 
       $select = $db -> select(); 
      $select -> from('ops_mobile_coupons') 
      -> where('id =?',$couponId); 

      $data = $db -> fetchRow($select); 
      $select = $db -> select() -> from('ops_image_type_coupon_details')->where('coupon_id = ?',$data['id']); 
       $x = $db->fetchRow($select); 

       $image=$x['image_path']; 

    //  -> andWhere('client_id = ?', $userId); 

       if(isset($fbpost) and $coupontype == 'image') 
      { 
    //Image Facebook Starts     

       $app_id = "APP_ID"; 
       $app_secret = "APP_SECRET"; 
       $facebook = new Facebook(array(
       'appId' => $app_id, 
       'secret' => $app_secret, 
       'cookie' => true, 
       'fileUpload' => true, 
       )); 



    $accounts_list = $facebook->api('/me/accounts'); 



       $accounts_list = $facebook->api('/me/accounts'); 

       //to get the page access token to post as a page 
       foreach($accounts_list['data'] as $account){ 
         if($account['id'] == 'me'){  // my page id =123456789 
         $access_token = $account['access_token']; 
         //echo "<p>Page Access Token: $access_token</p>"; 
         } 
        } 
       $attachment = array('message' => 'image coupon', 
           'access_token' => $access_token, 
           'link' => 'http://operture.com/jeegesh/index.php/octopus/adminhtml_coupon/postpart2/key/34f1bf523a35bc8c9213d669097f8e50/', 

           'source' => $image, 

           ); 
       $status = $facebook->api('/me/feed', 'POST', $attachment); // my page id =123456789 
       //var_dump($status); 
     } 
    //Image Facebook Ends }} 

答えて

2

redirect_uriあなたはアプリの設定でアプリの設定したURLと一致して使用しているのか?そうでない場合、アプリの認証はエラー191で失敗します(非管理者は特定の理由は表示されません)

関連する問題