duange2971 2015-10-31 03:59
浏览 62
已采纳

使用API​​在Twitter上发布到多个帐户。 获取重复状态错误。

Trying to post to twitter using laravel and this twitter API package. Im using a foreach loop to grab each of the account tokens and post but I keep getting the error Duplicate status because it seems like its not changing the tokens before its posting to twitter. I've tried to refresh the page and the break the connection, still getting the error.

here is my foreachloop

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.');
        }

Into the foreach loop im passing in 1. The social media I.D 2. The Oauth, secret tokens 3. The content to post

When I track the tokens using echo it seems to be getting all the right tokens but just not when posting to twitter. Could it be a connection issue? thats its not refreshing the connection for each account?

  • 写回答

1条回答 默认 最新

  • drl47263 2015-10-31 09:24
    关注

    Figured it out. For anyone else that has the same problem with the package. Don't use session:: commands in the foreach loop. Use the Twitter::reconfig method. Not sure why but on post the session wasn't changing the tokens while in the foreach loop no matter what I tried. Using the reconfig method solved all the token issues.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来