今回は純粋に個人的な覚書です。

やりたいことは、twitterから送信される「フォローされましたよ」メールを受信して、フォローとお礼をかえすというもので、現状はCronを使用しているのだが、あまりにもtwitterのapiが頻繁にエラーを返すので、その対策としてアプローチを変えようと思った次第。

つまり、メールを受信してキックするようにすれば無駄なapiへのアクセスが減るのではないかと。。。

以下は、関連する情報のURLをだらだらとメモっているだけです。

twitterからのメールのメールヘッダ

How should my bot follow users that follow it or inspect direct messages?

By default, Twitter sends an email the first time a user follows you or sends you a direct message.  For your bot-building pleasure, we’ve added the following headers to those emails

  • X-TwitterEmailType - will be ‘is_following’ or ‘direct_message’
  • X-TwitterCreatedAt - ex: Thu Aug 07 15:17:15 -0700 2008
  • X-TwitterSenderScreenName - ex: ‘bob’
  • X-TwitterSenderName - ex: ‘Bob Smith’
  • X-TwitterSenderID - ex: 12345
  • X-TwitterRecipientScreenName - ex: ‘john’
  • X-TwitterRecipientName - ex: ‘John Doe’
  • X-TwitterRecipientID - ex: 67890
  • X-TwitterDirectMessageID - ex: 2346346