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?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire