Tajemniczy Radny Tajemniczy Radny - 26 days ago 19
PHP Question

Laravel send tweet as user

Is it possible to send automatic tweets from laravel like user.
User must be logged by my twitter API, and then can I send tweet as him?Of course he must accept this action. I must know when user tweets my page.
Can it work like facebook share? Is there tools for this?

Sorry for my english.
Thanks for all answer.

PS.
I do not mean this package http://vegibit.com/send-a-tweet-with-laravel/ .
I need send tweets to user table.

Answer

Use this https://twitteroauth.com/ package.

Push in your console composer require abraham/twitteroauth When all installed then you should add use Abraham\TwitterOAuth\TwitterOAuth; to your class.

Now in function you must create connection with your api.

$connection = new TwitterOAuth(
CONSUMER_KEY, // Information about your twitter API
CONSUMER_SECRET, // Information about your twitter API
$access_token, // You get token from user, when him  sigin to your app by twitter api
$access_token_secret// You get tokenSecret from user, when him  sigin to your app by twitter api
);

If you created connection then you can send post as user. For example:

$connection->post("statuses/update", ["status" => "My first post!"]);