Twitter's API doesn't really support the notion of an application having agency to send direct messages on its own. Direct messages are between two Twitter users.
If you want your application to have an identity, it'll need to be a Twitter account also -- one that has approved your application. When you want your application to send a direct message to the user, you use the access token of your application's account. The gotcha here is that the user who is receiving the direct message needs to be following your application's user account. A common practice in this case is to suggest through a UI that the user follows that account to receive DMs. You must make the "following" aspect opt-in though. Taylor On Wed, Feb 2, 2011 at 10:39 PM, pl <[email protected]> wrote: > Trying to do an app that can send private messages to a user, these > messages could be sent at any time and would be triggered by real-time > events that require a notification to be sent to a registered user. > > Tried using the direct_message/new api and whilst that does send the > message, it appears to of been sent by the user that recieves it > rather than sent from the application. > > Example sequence used to get this: > > Registered user 1 > > Registered user 2 > > User 2 registered an application > > User 1 signed up to that application, application now has auth token, > secret, user_id and screen_name of user 1. > > At a later point, the application sends a private message to user 1 > using the direct_message/new api > > The message is recieved by user 1, but appears to be sent from user 1 > not from the application that user 2 registered. > > > How can I make it so that the message shows as from the application? > These are private messages so should only be visible to the recipient. > > -- > Twitter developer documentation and resources: http://dev.twitter.com/doc > API updates via Twitter: http://twitter.com/twitterapi > Issues/Enhancements Tracker: > http://code.google.com/p/twitter-api/issues/list > Change your membership to this group: > http://groups.google.com/group/twitter-development-talk > -- Twitter developer documentation and resources: http://dev.twitter.com/doc API updates via Twitter: http://twitter.com/twitterapi Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list Change your membership to this group: http://groups.google.com/group/twitter-development-talk
