在Facebook登录后重定向到同一页面,以便我可以相应地发布帖子


Redirecting to the same page after facebook login so that i can make posts accordingly

可能的重复项:
应在用户登录时提交表格

以下是我的代码,我一直在尝试制作一个脚本,如果我在 facebook 上发布的复选框被选中,那么首先将检查用户是否登录 facebook,但如果他不是,那么他将被重定向到 facebook 页面,登录到它并重定向回同一页面。我正在开发magento,当我检查checbox以在facebook上发布时,它会成功地将我重定向到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 }}

你正在使用的redirect_uri是否与你在应用设置中为应用配置的 URL 匹配? 否则,应用身份验证将失败并显示错误 191(非管理员不会看到具体原因)