How to get Complete (Both Sent and Received) Direct messages from Twitter api in single request? - iphone

Now i am able to get "Received Direct messages" from twitter and "Sent Direct messages" from twitter.
But i saw an iPhone application Seesmic where direct messages showing as original twitter messages page (Messages). In that iPhone application they showing both sent and received messages in single page.
I could do this by calling both webservices (http://api.twitter.com/version/direct_messages/sent.json,http://api.twitter.com/version/direct_messages.json) and merging both responses and showing it like original twitter inbox (means showing messages to each user as a separate page).
There are only four methods in Twitter Direct Messages
I want to know any other way of getting complete "Direct messages" from twitter in a single request.Is Streaming api is capable of that. There is no enough support in web for streaming api. Please answer me.Thanks in advance.

There is no single API method that provides this. You will have to make two requests and merge them locally. You could use the User Streams API but the streaming API does not provide any historical data. You would start with no DMs and slowly build up a local cache as DMs are sent/received by the user.

Related

In which format I should send http POST to Bot Builder?

I was trying to built a bot which interacts with multiple users.
The Microsoft Bot Builder seems nice to me.
I followed their examples and tried them out.
Bot Builder Restify and so on
There are few things which are not clear to me.
How can I post a message to bot rest endpoint?
The emulator seems to have been taking care of such details. But in a real application, in which format i should sent a message?
How does the bot interacts with multiple users? In the emulator, there is only one user, what happens if there are several persons talk to the bot at the same time in a real application?
I think "chatconnector" somehow doing the job, but I am not sure.
I hope someone could point out examples or give answers below to clarify these to me.
Thanks in advance!
1) Messages are sent using industry-standard REST and JSON over HTTPS. Although you can call the bot's endpoint directly, this would bypass channels and security. In the Microsoft Bot Framework architecture, clients communicate with a channel connector and the channel connector calls the bot. When the bot responds, it sends a message to the channel connector and the connector calls the client. The channel connectors transform messages from the channel's specific schema to the Bot Framework's generic activity schema and back. They also verify that callers are authorized using JWT tokens.
This documentation on Authentication might help clear things up some: https://learn.microsoft.com/en-us/bot-framework/rest-api/bot-framework-rest-connector-authentication
2) Group conversations are handled differently, depending on the channel. This sample demonstrates some of the group conversation features in the Bot Builder Node sdk: https://github.com/Microsoft/BotBuilder-Samples/tree/master/Node/core-GetConversationMembers

Facebook real time inbox messages with Graph API v2

Does anyone know a way to fetch a user/page inbox messages in real time?
I've found this link, but there is no mention about inbox messages.
The Real-time updates are about... -updates-. That means you will only get notified about changes in the fields described in that link (not regarding the Payments API, that's a different case).
So, you can't get real-time inbox messages.
You can subscribe to the notifications, but I'm not really sure if Messages notifications are included in those...

All Facebook messages from Graph API

I'm building an application for my personal use that saves all my facebook messages in a database on my computer.
But I have a problem as it seems only few messages can be accessed through the Graph API.
I created a token with all the possible permissions.
When issuing a call:
/me/inbox
I get all the threads in my inbox but for some of them the comments field which contains the actual messages is missing. It's mostly for conversation with people that are not friend with me on facebook.
For those threads, when I try to get more information by /<id_of_the_thread>
I get an error (code 100) Unsupported get request. from the graph api.
Is it a normal behaviour of the API?
What am I missing here?
Don't hesitate if you know a better way of saving all my messages.
Another, somewhat inferior, but much more accessible way of obtaining one's Facebook messages is by downloading a copy of your Facebook data through https://www.facebook.com/settings. This way you can download an archive with all your FB data, including your messages. They are however capped to 10,000 messages per conversation, and are all stored in one .htm file, which is not very practical if you want to do further operation on them.
No i think, we can't specified the Thread by using ID, but commonly i'm sorting the threads by its sender. CMIIW

Possibility on implementating sending Direct message using Twitter API

I would like to know how to send Multiple Direct message on Twitter. In my app using twitter api, i am able to send Direct message to one( Using DM Syntax ).
Currently i can see some tools like MultiDM website allows to send multiple Direct messages at a time.
So is that possible from iPhone's twitter api?
Also i wonder how the MultiDM website works as such
Pls let me know
In twitter API there is only 1 method of sending a DM: https://dev.twitter.com/docs/api/1/post/direct_messages/new
If you need to send multiple DM's - just call this method multiple times (with different recipient)
Yes you cant send DM to more than one user in a single call of the API.
If you want to send DM to multiple users, just make an array of all users id or screen name and in a loop send direct messages to All through the below API...
https://dev.twitter.com/docs/api/1/post/direct_messages/new

Realtime Twitter Replies?

I have created Twitter bots for many geographic locations. I want to allow users to #-reply to the Twitter bot with commands and then have the bot respond with the results. I would like to have the bot reply to the user as quickly as possible (realtime).
Apparently, Twitter used to have an XMPP/Jabber interface that would provide this type of realtime feed of replies but it was shut down.
As I see it my options are to use one of the following:
REST API
This would involve polling every X minutes for each bot. The problem with this is that it is not realtime and each Twitter account would have to be polled.
Search API
The search API does allow specifying a "-to" parameter in the search and replies to all bots could be aggregated in a search such as "-to bot1 OR -to bot2...". Though if you have hundreds of bots then the search string would get very long and probably exceed the maximum length of a GET request.
Streaming API
The streaming API looks very promising as it provides realtime results. The API allows you to specify a follow and track parameters. follow is not useful as the bot does not know who will be sending it commands. track allows you to specify keywords to track. This could possibly work by creating a daemon process that connects to the Streaming API and tracks all references to the bot's names. Once again since there are lots of bots to track the length and complexity of the query may be an issue. Another idea would be to track a special hashtag such as #botcommand and then a user could send a command using this syntax #bot1 weather #botcommand. Then by using the Streaming API to track all references to #botcommand would give you a realtime stream of all the commands. Further parsing could then be done to determine which bot to send the command to. This blog post has more details on the Streaming API
Third-party service
Are there any third-party companies that have access to the Twitter firehouse and offer realtime data?
I haven't investigated these, but here are a few that I have found:
Gnip
Tweet.IM
excla.im
TwitterSpy - seems to use polling, not realtime
tweethook
I'm leaning towards using the Streaming API. Is there a better way to get near realtime #-replies for many (hundreds) of Twitter accounts?
UPDATE: Twitter just announced that in the future they will have User Streams which expands upon the Streaming API. User Streams Preview
Either track or follow will work for the cases you describe. See http://apiwiki.twitter.com/Streaming-API-Documentation#track for details on what track actually does. The doc on follow is on the same page.
There are rate limits of sorts on the streaming API, but they have to do with how big a slice of the total tweet stream you're consuming. For writing a bot like this you won't hit these limits without a pretty big user base. And when you get that user base you can apply for elevated access levels that increase the rate limets.
There's the twitter firehose but you're probably best off using the Streaming API. The firehose is open to Google (try googling your twitter name) and as the link says they're opening it up to all soon enough.
You'll want to get your IP whitelist too.
If your not already, you want to check out the GoogleGroup for twitter devs.
The track predicate for the streaming api would actually be useful because if you follow your bot's user IDs, you'll get all the messages made by your bots and all the other messages that mention your bots #usernames (including #replies). It really does track everything public on twitter relating to the user IDs you follow with it, give it a shot.
REST API:
The most comprehensive results with the least amount of false positives. Will include protected statuses if the bot is following the protected account. If you poll every thirty seconds it is pretty close to realtime and you will be well under your rate limit (350/hour) if you are using api.twitter.com/1 with OAuth.
Streaming API:
You will want to avoid the Search API. It is trending more and more towards popular results and not complete results.
Streaming API
The fastest but also likely to miss some statuses as well as include false positives. Protected statuses for example are not included. Track for a screen_name will return statuses with that screen_name in it but will also include tweets that just have the screen_name as a string without the # so be sure to filter on your side.