【问题标题】:Post to multiple accounts on twitter using API. getting duplicate status error.使用 API 在 Twitter 上发布到多个帐户。出现重复状态错误。
【发布时间】:2016-01-31 13:58:43
【问题描述】:

尝试使用 laravel and this twitter API package 在 Twitter 上发帖。我使用 foreach 循环来获取每个帐户令牌并发布,但我不断收到错误重复状态,因为它似乎在发布到 Twitter 之前没有更改令牌。我尝试刷新页面并断开连接,但仍然出现错误。

这是我的 foreach 循环

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

进入我传入的foreach循环 1.社交媒体ID 2. Oauth,秘密令牌 3. 发布内容

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

【问题讨论】:

    标签: php api twitter twitter-oauth laravel-5.1


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2016-08-26
      • 1970-01-01
      • 2015-08-30
      • 1970-01-01
      • 1970-01-01
      • 2011-05-31
      • 2013-11-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多