In my previous post, I provided a tool to help you get a Buddy Updates feed. In this post, I will cover how you can programmatically push an item to this feed.
The first thing you should know before using this API is that you should observe some basic rules of netiquette:
- Don’t push anything without checking with the user first.
- Don’t persist any permission granted by the user unless you inform them of such persistence.
- Provide a place where the user can view and edit their permission to push items to their feed.
Please keep the above rules in mind as you write clients and plugins that push data to a user’s Buddy Updates feed.
Version 1.6.8 of the AIM SDK provides an interface that you can use to push just about anything to the user’s Buddy Updates Feed. This is the same API used by the AIM client to push all plugin installs.
To push an item to this feed you will need to do get the buddy feed manger (IAccBuddyFeedManager) from the session (IAccSession), create a buddy feed item (IAccBuddyFeed), set its properties, and finally push the item via the buddy feed manager. Here is a simple function that adds a test item to the feed:
HRESULT PushTestFeed(IAccSession *pSession) { CComPtr<IAccBuddyFeedManager> spFeedManager; if ( SUCCEEDED( get_BuddyFeedManager(pSession, &spFeedManager) ) ) { CComPtr<IAccBuddyFeed> spFeed; if ( SUCCEEDED( spFeedManager->CreateBuddyFeed( &spFeed ) ) ) { put_FeedTitle(spFeed, CComBSTR(OLESTR("Feed Title")) ); put_FeedLink(spFeed, CComBSTR(OLESTR("Feed Link"))); put_FeedDescription(spFeed, CComBSTR(OLESTR("Feed Description"))); put_FeedPublisher(spFeed, CComBSTR(OLESTR("Feed Publisher"))); put_ItemTitle(spFeed, CComBSTR(OLESTR("Item Title"))); put_ItemLink(spFeed, CComBSTR(OLESTR("Item Link"))); put_ItemDescription(spFeed, CComBSTR(OLESTR("Item Descrtiption"))); put_ItemGuid(spFeed, CComBSTR(OLESTR("Item GUID"))); put_ItemCategory(spFeed, CComBSTR(OLESTR("Item Category"))); AccTransId transId; return spFeedManager->Push(spFeed, &transId); } } return E_FAIL; }
The result of pushing the above content to my feed is shown here:
... <item> <title>Feed Title : Item Title</title> <link>Item Link</link> <description>Item Description</description> <author>gusblog</author> <aimId>gusblog</aimId> <pubDate>Wed, 28 Jan 2009 10:00:00 GMT</pubDate> <category>Item Category</category> <origFeedTitle>Feed Title</origFeedTitle> <origFeedLink>Feed Link</origFeedLink> <guid>Item Guid</guid> </item> ...
AIM uses the feed’s link as the source for the favicon.ico when rendering it in the client and on the web. You must be in the online state before you can push an item. Pushing an item with an existing item GUID in the feed will replace the current content.
Tags: C++, Open AIM, Sample Code