使用API发布到twitter上的多个帐户.获取重复状态错误


Post to multiple accounts on twitter using API. getting duplicate status error.

尝试使用laravel和这个twitter API包发布到twitter。我使用foreach循环来获取每个帐户令牌并发布,但我一直得到错误Duplicate状态,因为它在发布到twitter之前似乎没有更改令牌。我已经尝试刷新页面并断开连接,但仍然收到错误。

这是我的前臂环

foreach ($post['accountsToPost'] as $accountToPost) {
            $uniqueProfile= DB::table('profiles')->where('social_media_id', $accountsToPost)->first();
            $new_token = [
                'oauth_token'        => $uniqueProfile_test->oauth_token,
                'oauth_token_secret' => $uniqueProfile_test->oauth_secret,
                'x_auth_expires'     => $uniqueProfile_test->x_auth_expires,
            ];
            Session::forget('access_token');
            Session::put('access_token', $new_token);
            Twitter::postTweet(['status' => $post['post_text'], 'format' => 'json']);
            Session::flash('flash_message', 'Success! Your post has been sent.');
        }

进入前臂循环1.社交媒体ID2.Oauth,秘密代币3.发布的内容

当我使用echo跟踪令牌时,它似乎得到了所有正确的令牌,但在发布到twitter时却没有。可能是连接问题吗?这不是刷新每个帐户的连接吗?

想明白了。对于其他有同样问题的人。不要在foreach循环中使用session::命令。使用Twitter::reconfig方法。不知道为什么,但在帖子中,无论我尝试了什么,会话在foreach循环中都没有更改令牌。使用reconfig方法解决了所有令牌问题。