There is no completely standardized way to do this; the most portable solution is to open a temporary file, write data to it, and hand it to the lexer. Here's a sample bit of code to do this.
And Amplifeeder can also generate a nice, data-portable XML file for users to backup all their social stream's data; XML files can also be used to restore data.