php - How to post tweets to multiple twitter accounts through "thujohn/twitter" library in Laravel? -
how use thujohn/twitter
library in laravel framework post tweets multiple accounts manage on twitter.com?
i have faced same problem when i've tried publish on multiple twitter accounts before , i've solved this:
first: need create twitter app each twitter account manage, , each app need these data:
- api key (consumer key)
- api secret (consumer secret)
- access token
- access token secret
and here how going use them:
// set twitter app data of twitter account going publish to.. if (some_condition) { $consumer_key = "account_consumer_key"; $consumer_secret = "account_consumer_secret"; $access_token = "account_access_token"; $access_token_secret = "account_access_token_secret"; } else if (some_other_condition) { $consumer_key = "account_consumer_key"; $consumer_secret = "account_consumer_secret"; $access_token = "account_access_token"; $access_token_secret = "account_access_token_secret"; } // set new configurations twitter::reconfig([ "consumer_key" => $consumer_key, "consumer_secret" => $consumer_secret, "token" => $access_token, "secret" => $access_token_secret, ]); $tweet = [ 'status' => "some text doesn't exceed 140 characters", ]; $tweet_result = twitter::posttweet($tweet);
more info , credits goes to: hafsal
Comments
Post a Comment