Facebook Messages access via imap - facebook

Does anybody know if is possible to access facebook messages via imap or pop to manage facebook messages within an email client?

No, this is not possible. Only the publicly documented APIs are available.
See especially the inbox connection of the User object

This Article propose a way to read and store facebook message:
The process is done through the following steps:
Logging in : Logging in might be one of the trickier parts. The way you login to an IMAP server is to use the following command:
LOGIN username password
Listing folders : The command you’d issue to the IMAP server is:
LIST "" *
Since we know from the Mailbox folder API description, there are only
three folders. These folders are:
Inbox (folder_id 0)
Outbox (folder_id 1)
Updates (folder_id 4)
With this in mind, we can hard code the following response to the list
command:
LIST (\HasChildren) "/" Inbox
LIST (\HasChildren) "/" Outbox
LIST (\HasChildren) "/" Updates
Selecting a folder : In IMAP, you use the following command to select a folder:
SELECT folder-name
Getting message content: The key in getting messages trough IMAP is a command named FETCH. The FETCH command comes with a lot of
different modes, but we’ll focus on the most fundamental ones. These
are (AFAIK) FLAGS, RFC822, RFC822.HEADER, RFC822.TEXT, RFC822.SIZE and
UID. Since RFC822 is just RFC822.HEADER and RFC822.TEXT combined, we
have one less variable to worry about.
FETCH UID Let’s start with UID, as this is the easiest one. You’d issue this command as follows:
FETCH 1:6 (UID)
The expected result would look something like this:
1 FETCH (UID 1029955483)
2 FETCH (UID 1029955484)
3 FETCH (UID 1029955485)
4 FETCH (UID 1029955486)
5 FETCH (UID 1029955487)
6 FETCH (UID 1029955488)
The equivalent command in Facebook’s API would be something like this
(I’m not sure if it’s possible to combine queries like this, but you
get the idea):
SELECT message_id FROM message WHERE thread_id IN (SELECT thread_id FROM thread WHERE folder_id = 0)
You would then use that output as the UID.
More operations are available in http://www.emailserviceguide.com/2010/01/making-facebooks-messaging-system-imap-compatible/

Related

where find clientid from console

I need to send some mails my users.
I will send it from console, so I have not any user's cookies.
And to track opening mails I insert img in letter body like this:
<img src="https://www.google-analytics.com/collect?v=1&tid={{UA}}&cid={{CID}}&uid={{UID}}..." alt="" />
How can I replace {{CID}} ?
Where should I find it?
Thanks
If you want this hit to be connected to an existing user from your website you would need to record the client id when a user signs up for your emails, maintain a database that maps the recorded id to the e-mail address and the actual substitution would depend on your mail script. Since in this case the clientid is created in your users browser the only possible source would be the cookie.
If you just want to record a hit (without connecting it to existing users) then, as DalmTo pointed out, just use a random unique id.
If you do not have a client id, but have a way to identify the user on your website then you could also try the UserId feature and session unification. In this case you would use a random client id and append your known user id as parameter.
You should refer to the measurement protocol documentation
Protocol Version v v=1 The protocol version. The value should be 1.
Tracking ID tid tid=UA-123456-1 The ID that distinguishes to which Google Analytics property to send data.
Client ID cid cid=xxxxx An ID unique to a particular user.
Hit Type t t=pageview The type of interaction collected for a particular user.
this may also help Email Tracking - Measurement Protocol
How can I replace {{CID}} ? Where should I find it?
It should be a unique number identifying this user, its basically used for session control. Random Guid works.

java imap, performance issues, fetching all mails

I will use java mail api to handle mails like thunderbird etc. I have to fetch mails having 1000 messages. My design will be: When user performs a synch on a folder, i will get all uids of the messages in the folder:
Message[] msgs = ufolder.getMessagesByUID(1, UIDFolder.LASTUID);
// Use a suitable FetchProfile
FetchProfile fp = new FetchProfile();
fp.add(FetchProfile.Item.ENVELOPE);
fp.add(FetchProfile.Item.FLAGS);
I wil then compare the list of uids with the list stored in my db.
For the deleted ones, for example a message is not in the folder but in the db, i will mark it as deleted.
For the new ones, for example a message is in the folder but not in the db, i will mark as possible new. But, because messageuids are not safe (can be changed by the mail server on some cases), for the new mails, i will use additioanlly a custom hash value build from message id in the header + subject + receivedate and build a md5 hash. Only for the possible new mails i will use this hash and catch new mails.
For the moved messages, because their uids will be changed in the new folder, it will be flagged as deleted in the first and will be a new message in new folder, but the message will have same custom hash value becaue message id in the header and other properties will remain same duing the movement.
Question about performance issue: On each click on folder (folder synch) i will do the compare operation of all uids in the folder with the local uid list stored in the db to learn the deleted ones. I could not find another better way to accomplish this. As you know, thunderbird catches immediately a deleted message without relogin, even if the folder is large and the deleted message is very old (5 years). I think thunderbird also compares all message uids in that folder with a list stored locally.
How can i implement a better mechanism for the synch for a better performance? Does thunderbird apply a different approach? How can thunderbird
accomplish it so quickly?
If we were interested only for the new messages, i could have kept last stored uid and only compare the new messages later than that, but for the deleted ones, i already have to compare full folder. Additionally, UIDNEXT value is always -1 in my mail server, if it were set correctly, it will not help to get deleted ones again, a full compare is a must i think, am I wrong?
Note: I canot not use or add message listeners because the appliaction is server-client based and the mail handling task is on the server side and we do not support threads listeners etc. The events should be triggered from the client and the request is being processed on ther server and a response is returned and client handles the response on the gui.
What you want is called condstore or quick resync, RFC7162 in both cases. That's what Thunderbird uses.
That's a pair of extensions support commands like "give me all the UIDs that have changed since last time I connected", "tell me what's been deleted" and so on.
If you can't use threads to listen for these events from the mail server, your options are very limited. Probably the best thing you can do is limit the resynchronization to the messages that are visible to the client.

Retrieve the list of UIDs in an Imapfolder with MailKit?

I want to send the command 'UID FETCH ALL'. This gives me all the uids for this folder. I can't find any predefined method for this command.
I want to retrieve the headers of the emails in an imapfolder and save them to a local datastore with their UID so the next time, I can fetch all the UIDs, discard the ones smaller then the highest UID in my datastore and start retrieving those headers.
Additionally I can compare the range of UIDs in my datastore with the list retrieved by the command and check if any UIDs failed to be persisted to my local datastore en try to receive them again.
(Assume checking of the UIDs is in conjunction with UIDValidity).
I use this strategy to be sure all headers are in my local datastore (or my logging tells me which UID I can not retrieve/persist)
If there is another (possible better) strategy to accomplish this with MailKit please point me in the right direction.
Update:
Found a solution. Use 'inbox.Fetch(0, -1, MessageSummaryItems.UniqueId)'
Found a solution. Use 'inbox.Fetch(0, -1, MessageSummaryItems.UniqueId)'

Proper REST URL format

My REST API format:
http://myserver.com/rest/messages - get all messages
http://myserver.com/rest/messages/5 - get message with id=5
How should the URL look when I want to get all messages owned by a user with id=1?
http://myserver.com/rest/messages/user/1
OR
http://myserver.com/rest/usermessages/1 (no such entity UserMessage exists in the system)
This sounds like a filter/search for messages. This is usually done by query parameters:
GET http://myserver.com/rest/messages?ownedBy=1
Since /messages is a collection resource from which you want a subcollection, you filter it.

IMAP: Search for messages with UID greater than X (or generally, after my last search)

I'm writing a script to analyze my mailbox and want to periodically check for new messages. The search criteria would be: give me the UIDs for all emails with UID greater than X, where X is the UID of the last email I processed.
Or, more generally, I'm looking for a way to only see messages since my last search.
Note that I'm not looking for seen/unseen messages; the script opens the mailbox as read-only, and I'd like it to not interfere with my flags, etc.
I know I can specify a date in the IMAP search, but the granularity of that seems to be by day, so not exactly what I need.
I'm starting with Gmail as the IMAP server, but would like to support generic IMAP servers in the future.
Is there way to search for emails with UID greater than X? Or another means of specify all messages since message X?
You can use IMAP SEARCH for UIDs. Assuming your most recently fetched UID is 1999, I think you would do:
SEARCH UID 2000:*
Why not use IMAP IDLE for this?
with IMAP IDLE, the server warns you every time a new message arrives