Allowing my app users to post tweets from a single

2019-07-15 13:06发布

I have a small application that display traffic issues on public transportation in my small country: Belgium.

I made a system in the application that allow users to warn all people when there is delay on the trains, for instance.

What I would like to do is to allow my trusted users to tweet from my account something like "User X said 3 minutes delay on train 123456"

SO basically, i would like to hardcode the twitter username and password in the code and send the tweet, as I have all the credentials. (basically, I would also check that I post only 1 or 2 tweets an hour)

I have read the twitter documentation, but couldn't find any information on that.

It think that's possible via php:

curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $twitter_data);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERPWD, "{$twitter_user}:{$twitter_password}");

from here: http://www.webmaster-source.com/2009/04/05/post-to-twitter-from-a-php-script/

3条回答
萌系小妹纸
2楼-- · 2019-07-15 13:16

You would have to have your own server that the application sends messages to. Upon receipt of a message, your app would then use oauth to log in to twitter and post the message using your credentials.

There are twitter and/or oauth libraries available for a lot of different languages and web apps, so it should be pretty easy to set something up.

If you go this route, you should register your (server) app on twitter, and then you'll have the keys you need to get started.

查看更多
时光不老,我们不散
3楼-- · 2019-07-15 13:18

You can't do this. As Twitter API has rate limit, you can't send request unlimited API requests. You can have maximum 350 requests per hour. The account will cross rate limit within a few minutes if number of user tries to use the same account

查看更多
该账号已被封号
4楼-- · 2019-07-15 13:28

You have to authorize the twitter users. The former username and password curl method is no longer allowed. You should run a cron-job for this. When the users sigh in you save their authentication paramaters

You can check here for libraries that allow you do this easily. Twitter Library

查看更多
登录 后发表回答