Powershell - work with MetaAPI to post a blog entry
The Request Parameters is incorrect, the correct format should be http://lieb.cn/MetaAPI/default.aspx?usr=rsstext&psd=china&Tit=Hello&Des=TheEncodedBlogEntryBody&Cat=None
Please
enable E-mail publishing in Space Options
page at first and set the "Step 4: Select your publishing settings" to
"Publish entries immediately" !
The url will be generated in powershell like below:
http://lieb.cn/MetaAPI/default.aspx?usr=rsstext&psd=china&Tit=Hello&Des=TheEncodedBlogEntryBody&Cat=None
A new blog entry will be published once you access this link.
Parameter:
usr: Your space alias http://
rsstext.spaces.live.com
psd: The Secret word you created in Step 2 in Spaces Edit View -> Options ->
E-mail publishing page.
Tit: The title of new blog entry.
Des: The blog entry body, need to encode first.
Cat: The category of the Blog entry, type "None" by default.
Purpose:
1.)
Create a blog entry. Either
using Blogit or
MetaAPI.
2.) Subscribe to the Feed (in otherwords just go read it)
3.) Compare what you get to a file that you already put the results in.
4.) If the contents are different then the test case fails, if the same then they
pass.
The powershell parameter values will run through the code below in this page:
string Usr = this.Request.QueryString["usr"];
string Psd = this.Request.QueryString["psd"];
string Tit = this.Request.QueryString["Tit"];
string Des = this.Request.QueryString["Des"];
string Cat = this.Request.QueryString["Cat"];
if (String.IsNullOrEmpty(Usr) || String.IsNullOrEmpty(Psd) ||
String.IsNullOrEmpty(Tit) || String.IsNullOrEmpty(Des) || String.IsNullOrEmpty(Cat))
{
Label1.Text = "The Request Parameters is incorrect, the correct format should be
http://lieb.cn/MetaAPI/default.aspx?usr=rsstext&psd=china&Tit=Hello&Des=TheEncodedBlogEntryBody&Cat=None";
}
else
{
string sUsername = this.Request.Params["usr"].ToString();
string sPassword = this.Request.Params["psd"].ToString();
string sTitle = this.Request.Params["Tit"].ToString();
string sDescription = this.Request.Params["Des"].ToString();
string sCategory = this.Request.Params["Cat"].ToString();
if (String.IsNullOrEmpty(sUsername) || String.IsNullOrEmpty(sPassword))
{
Label1.Text = "The space alias or secret word is empty, please retype vaules in
powershell.";
}
else
{
if (String.IsNullOrEmpty(sTitle))
{
sTitle = "New Blog Entry" + DateTime.Now.ToString();
}
if (String.IsNullOrEmpty(sDescription))
{
sTitle = "Blog Entry Body - For Testing Purpose." + DateTime.Now.ToString();
}
if (String.IsNullOrEmpty(sCategory))
{
sCategory = "None";
}
sDescription = Server.HtmlEncode(sDescription);
GetMyAPI.getBelem_fromAPI myAPI = new GetMyAPI.getBelem_fromAPI();
try
{
myAPI.postYourInfo(sUsername, sPassword, sCategory, sTitle, sDescription);
this.Response.Redirect("Done.aspx");
}
catch (Exception ex)
{
Label1.Text = ex.Message.ToString();
}
}
}