通过API发布到Facebook时的连续循环重定向

时间:2014-05-09 13:14:28

标签: php facebook yii

这是我的代码:

$app_id = '1xx66xxxxx337499';
        $app_secret = '4545daed40xxxxxx5d6649c82d3e983';
        $redirect_url = 'http://localhost/linkmo/site/registerfacebookuser';

        $status = "Testing the waters";
        $description = "here is product description";
        $link = 'http://demo.microgigz.com/linkmo';
        $name = "Product name";

        Yii::import("application.extensions.facebooksdk.Facebook");
        $config = array();
        $config['appId'] = $app_id;
        $config['secret'] = $app_secret;
        $fb = new Facebook($config);

        $user_facebook_information = UserSocials::model()->findbyAttributes(array('user_id' => Yii::app()->user->id));
        $current_access_token = $user_facebook_information->fb_access_token;
        $facebook_id = $user_facebook_information->facebook_id;

        $params = array(
            // this is the main access token (facebook profile)
            "access_token" => $current_access_token,
            "message" => $status,
            "link" => $link,
            "name" => $name,
            "caption" => "www.linkmo.com",
            "description" => $description
        );

        $ret = $fb->api('/' . $facebook_id . '/feed', 'POST', $params);
        Yii::app()->user->setFlash('posted_to_fb', 'Your message has been posted to facebook successfully!');
        $this->redirect('dashboard');

所有内容在访问令牌等方面都是有效的,我可以成功地通过API在Facebook上发布,但问题是每当我使用$this->redirect('dashboard');代替1状态时,它会发布10+状态并且不会重定向到仪表板。

任何人都能解释一下是什么原因吗?

0 个答案:

没有答案