0

可能重复:
提交表单应在用户登录时完成

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

1 回答 1

2

您使用的 URL是否redirect_uri与您在应用设置中为应用配置的 URL 匹配?如果没有,应用程序身份验证将失败并出现错误 191(非管理员不会看到具体原因)

于 2012-05-01T23:35:22.493 回答