Twitter's direct messaging functionality is great. While simple tweeting communicates "just a clever quip," direct messaging communicates "listen here b*tch, this is important enough that you need to get this message NOW via text message." Twitter's API allows you direct message remotely so now you can let your website DM you (and call you a b*tch) any time you want!
Twitter的直接消息传递功能很棒。 简单的推文交流“只是一个聪明的傻瓜”,而直接消息传递则交流“在这里听,这很重要,以至于您需要立即通过文本消息获得此消息”。 Twitter的API允许您远程定向消息,因此,现在您可以随时让您的网站DM您(并称您为ab * tch)!
Shell cURL命令 (The Shell cURL Command)
curl -u davidwalshblog:myPass -d "text=Testing a remote direct message via CURL&user=fellowTweeter" http://twitter.com/direct_messages/new.xml
This example shows the cURL command as you'd type it in the terminal.
此示例显示了在终端中键入cURL命令的过程。
PHP用法 (PHP Usage)
$result = shell_exec('curl -u davidwalshblog:myPass -d "text=Testing a remote direct message via CURL&user=fellowTweeter" http://twitter.com/direct_messages/new.xml');This is how you could use the command in PHP.
样本XML响应 (Sample XML Response)
186275699 15759583 Testing a direct message. 15759583 Sat Jun 20 00:13:41 +0000 2009 davidwalshblog davidwalshblog 15759583 davidwalshblog davidwalshblog Madison, WI, US Flexile Programmer, MooTools Core Team Member, JavaScript Fanatic, CSS Tinkerer, PHP Hacker, and web lover. http://s3.amazonaws.com/twitter_production/profile_images/57860553/footer-logo_normal.jpg https://davidwalsh.name false 1834 EEEEEE 000000 2A447B CDCDCD 999999 20 Thu Aug 07 04:18:53 +0000 2008 3 -21600 Central Time (US & Canada) http://s3.amazonaws.com/twitter_production/profile_background_images/15318223/twitter-background.png false 1734 false false false 15759583 davidwalshblog davidwalshblog Madison, WI, US Flexile Programmer, MooTools Core Team Member, JavaScript Fanatic, CSS Tinkerer, PHP Hacker, and web lover. http://s3.amazonaws.com/twitter_production/profile_images/57860553/footer-logo_normal.jpg https://davidwalsh.name false 1834 EEEEEE 000000 2A447B CDCDCD 999999 20 Thu Aug 07 04:18:53 +0000 2008 3 -21600 Central Time (US & Canada) http://s3.amazonaws.com/twitter_production/profile_background_images/15318223/twitter-background.png false 1734 false false false /direct_messages/new.xml You cannot send messages to users who are not following you.
Loads of information if your DM is successful -- a simple error response if your attempt fails.
如果您的DM成功,则会加载大量信息-如果尝试失败,则是简单的错误响应。
So why automate a DM? I think one handy time to implement direct message automation is when you want to receive text messages when events occur on the website. Say you're a salesperson and you have a "request a phone call" form on your site. Since you're out of the office much of the day (driving), you don't have the means to check your email. Instead of setting up a text messaging / SMS system, simply set up a Twitter account and take advantage of Twitter's texting capabilities.
那么,为什么要自动化DM? 我认为实现直接消息自动化的一个方便时间是当您希望在网站上发生事件时接收文本消息时。 假设您是销售人员,并且在您的网站上有一个“请求电话”表格。 由于您一天中大部分时间不在办公室(开车),因此您无法检查电子邮件。 无需设置短信/ SMS系统,只需设置一个Twitter帐户并利用Twitter的短信功能即可。
Would you ever want automated tweets or direct messages from your website?
您是否要从网站上自动发送推文或直接发送消息?
翻译自: