Could you expose some additional metadata on TimelineItemContainers please?

3 views
Skip to first unread message

Zhaph

unread,
Feb 7, 2012, 4:00:16 PM2/7/12
to Seesmic Desktop Platform Development
Hello,

In my plug-in (Doodle Grouper) the user can group the people they
follow on twitter, friends from Facebook, etc. into their own time
lines.

I would like my plug-in to also send re-tweets to these time lines,
however I'm finding it rather tricky to confirm that a tweet is a
"new" retweet and also get the details of the user that retweeted it
to send the tweet into the correct time line.

I currently have something like the following:

<pre>
// If this is a retweet this is the username of the original tweeter:
string userName = timelineItemContainer.TimelineItem.Username;

// Only interested in Tweets from the Twitter plugin.
if (timelineItemContainer.TimelineItemType.FullName ==
"Seesmic.Sdp.Plugins.Twitter.TwitterTimelineItem")
{
//Gets the raw data as sent by twitter.
var rawMetadata =
timelineItemContainer.Metadata.Where(m => m.Key ==
"com.seesmic.twitter.item").Select(m => m.Value).
SingleOrDefault();

if (null != rawMetadata)
{
string itemMetadata = rawMetadata.ToString();
// This accurately identifies retweets, however note the need for
double check for a space
if (itemMetadata.Contains("\"retweeted_status\": {") ||
itemMetadata.Contains("\"retweeted_status\":{"))
{
DoodleGrouperPlugin.LogInfo("Timeline Item is a re-tweet, working
out re-tweeter's name");
}
}
else
{
DoodleGrouperPlugin.LogError("Could not load Raw Metadata for
TimelineItem");
}
}
</pre>

However at this point I'm rather stuck. Part of the issue is that it
seems a bit excessive to re-write the code the parse the tweet JSON
into an object just to pull out two fields - especially as I'd need to
take a dependency on the same DLL that you are already using in the
TwitterPlugin.

Would it be possible to add the other public fields of the
TwitterTimeLineItem to the TimelineItemContainer metadata collection?

Many thanks,

Ben

George Ionita

unread,
Feb 13, 2012, 6:16:41 AM2/13/12
to seesmic-d...@googlegroups.com
Hi Ben,
 
We opened the original JSON source of the tweet exactly to support scenarios like yours, in a general way. Adding separately the fields that you need would create redundancy on our end just to solve a particular case, and long term this generates support cost and regression risks.
I understand that if you would use the same library for JSON parsing as we do in our plugin you would take an important risk because of the version collisions that might happen or breaking changes, but what if you use the System.Json classes to do the parsing and extract the data you need? This should keep you away from hassle.
 
George 

Zhaph

unread,
Feb 13, 2012, 11:33:55 AM2/13/12
to Seesmic Desktop Platform Development
Hi George,

Thanks for the reply, and for pointing me in the direction of
System.Json - I think this was the missing piece of the puzzle for me
- my other concern with using something like Json.Net or similar was
that I'd need to create an entire Twitter object to host it - but the
way System.Json works seems to save me that bother.

I'll push out an update this evening :)

Cheers,

Ben
Reply all
Reply to author
Forward
0 new messages