【发布时间】: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