允许我的应用程序用户从单个帐户发布推文

发布于 2024-12-08 00:39:32 字数 804 浏览 0 评论 0原文

我有一个小应用程序,可以显示我的小国家:比利时的公共交通交通问题。

例如,我在应用程序中创建了一个系统,允许用户在火车延误时警告所有人。

我想做的是允许我信任的用户从我的帐户发推文,例如“用户 X 说 123456 号火车晚点 3 分钟”,

所以基本上,我想在代码中硬编码 Twitter 用户名和密码并发送推文,因为我拥有所有凭证。 (基本上,我还会检查我是否每小时只发布 1 或 2 条推文)

我已阅读 Twitter 文档,但找不到任何相关信息。

它认为通过 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}");

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

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/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

紫瑟鸿黎 2024-12-15 00:39:32

您必须拥有自己的服务器来供应用程序发送消息。收到消息后,您的应用程序将使用 oauth 登录 twitter 并 使用您的凭据发布消息

有适用于许多不同语言和 Web 应用程序的 twitter 和/或 oauth 库,因此设置应该很容易。

如果您选择这条路线,您应该在 Twitter 上注册您的(服务器)应用,然后您将拥有您开始使用所需的密钥。

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.

稀香 2024-12-15 00:39:32

您必须授权 Twitter 用户。不再允许以前的usernamepasswordcurl方法。您应该为此运行一个 cron 作业。当用户叹气时,您保存他们的身份验证参数,

您可以在此处查看允许您轻松执行此操作的库。
Twitter 库

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

甚是思念 2024-12-15 00:39:32

你不能这样做。由于 Twitter API 有速率限制,因此您无法发送无限制的 API 请求。您每小时最多可以有 350 个请求。如果多个用户尝试使用同一帐户,该帐户将在几分钟内跨越速率限制

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文