Post 使用 API 到 Twitter 上的多个帐户。收到重复状态错误。
Post to multiple accounts on twitter using API. getting duplicate status error.
正在尝试 post 使用 laravel and this twitter API package 发 Twitter。我正在使用 foreach 循环来获取每个帐户令牌和 post,但我一直收到错误重复状态,因为它似乎在 posting 到 Twitter 之前没有更改令牌。我尝试刷新页面并断开连接,仍然出现错误。
这是我的 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.');
}
进入foreach循环我传入
1. 社交媒体 I.D
2. Oauth,秘密令牌
3.内容为post
当我使用 echo 跟踪令牌时,它似乎获得了所有正确的令牌,但在 post 访问 Twitter 时却没有。会不会是连接问题?那不是刷新每个帐户的连接吗?
想通了。对于对包裹有同样问题的任何其他人。不要在 foreach 循环中使用 session:: 命令。使用 Twitter::reconfig 方法。不知道为什么,但是在 post 上,无论我尝试什么,会话都没有在 foreach 循环中更改令牌。使用重新配置方法解决了所有令牌问题。
正在尝试 post 使用 laravel and this twitter API package 发 Twitter。我正在使用 foreach 循环来获取每个帐户令牌和 post,但我一直收到错误重复状态,因为它似乎在 posting 到 Twitter 之前没有更改令牌。我尝试刷新页面并断开连接,仍然出现错误。
这是我的 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.');
}
进入foreach循环我传入 1. 社交媒体 I.D 2. Oauth,秘密令牌 3.内容为post
当我使用 echo 跟踪令牌时,它似乎获得了所有正确的令牌,但在 post 访问 Twitter 时却没有。会不会是连接问题?那不是刷新每个帐户的连接吗?
想通了。对于对包裹有同样问题的任何其他人。不要在 foreach 循环中使用 session:: 命令。使用 Twitter::reconfig 方法。不知道为什么,但是在 post 上,无论我尝试什么,会话都没有在 foreach 循环中更改令牌。使用重新配置方法解决了所有令牌问题。