---電子發票整合方案 http://rd-program.blogspot.com/2012/03/blog-post.html---
<imoo msn機器人測試平台,將於下週三(2009.6.24)取消所有未經申請試用的認證資訊,詳見相關資訊>
msnSDK訊息控制開發套件 同時支援MSN/Yahoo即時通 訊息雙向傳遞
ps.也請參考 msnSDK的使用流程
================================
全域的物件及變數
WebClient wc = new WebClient();
string SPID = "";
步驟一:取得SPID(GETSPID)
private void button1_Click(object sender, EventArgs e)
{
string url="http://59.120.234.84:8082/msnSDK/msn_cgi-win32";
string method="POST";
string postdata = "FUNC=GETSPID&USERID=apiblogt2&PASSWD=msnsdkt";
byte[] postbyte=Encoding.UTF8.GetBytes(postdata);
byte[] resb = wc.UploadData(url, method, postbyte);
string resmsg = Encoding.UTF8.GetString(resb);
resmsg = resmsg.Replace("\n", "");
string[] arrstr = resmsg.Split('\t');
if (arrstr[0] == "1")
{
SPID = arrstr[1];
MessageBox.Show("取得SPID成功: SPID= " + SPID);
}
else
{
SPID = "";
MessageBox.Show("取得SPID失敗: " + resmsg);
}
}
步驟二:將帳號註冊為msn機器人的連絡人(REGISTER)
下述: txtmsnacc.Text 為msn/yahoo帳號
private void button2_Click(object sender, EventArgs e)
{
string url = "http://59.120.234.84:8082/msnSDK/msn_cgi-win32";
string method = "POST";
string postdata = "FUNC=REGISTER&uids=" + txtmsnacc.Text + "&session=" + SPID;
byte[] postbyte = Encoding.UTF8.GetBytes(postdata);
byte[] resb = wc.UploadData(url, method, postbyte);
string resmsg = Encoding.UTF8.GetString(resb);
resmsg = resmsg.Replace("\n", "");
string[] arrstr = resmsg.Split('\t');
if (arrstr[0] == "1")
{
MessageBox.Show("註冊成功: " + resmsg);
}
else
{
MessageBox.Show("註冊失敗: " + resmsg);
}
}
步驟三:發送訊息(SENDMSG)
private void button3_Click(object sender, EventArgs e)
{
string msg = "msnSDK測試訊息";
string url = "http://59.120.234.84:8082/msnSDK/msn_cgi-win32";
string method = "POST";
string postdata = "FUNC=SENDMSG&uids=" + txtmsnacc.Text + "&msg=" + msg + "&encoding=utf-8&flags=0&session=" + SPID;
byte[] postbyte = Encoding.UTF8.GetBytes(postdata);
byte[] resb = wc.UploadData(url, method, postbyte);
string resmsg = Encoding.UTF8.GetString(resb);
resmsg = resmsg.Replace("\n", "");
string[] arrstr = resmsg.Split('\t');
if (arrstr[0] == "1")
{
MessageBox.Show("發送訊息成功: " + resmsg);
}
else
{
MessageBox.Show("發送訊息失敗: " + resmsg);
}
}
其他更詳細的參數可以參考msnSDK訊息控制開發套件程式介面說明書
No comments:
Post a Comment