|
我的思路是这样的:
1、用webBrowser1登录到优酷访客空间上去
2、用GetCookies获取webBrowser1登录的cookies
3、直接用HttpHelper 向优酷的URL留言:http://i.youku.com/u/UMzE3MDIzMz ... ge?__rt=1&__ro=
HttpHelper http = new HttpHelper();
//创建Httphelper参数对象
HttpItem item = new HttpItem()
{
URL = webBrowser1.Url.ToString() + @"/guestbook/fun_message?__rt=1&__ro=",//URL 必需项
Method = "post",//URL 可选项 默认为Get
ContentType = "application/x-www-form-urlencoded; charset=UTF-8",//返回类型 可选项有默认值
Postdata = "to_user_id=" + userid + "&sync_renren=0&sync_sina=0&sync_tencent=0&sync_messenger=0&sync_qzone=0&sync_kaixin=0&text=" + Uri.EscapeDataString(richTextBox2.Lines[xx].ToString()),//Post要发送的数据
Cookie = GetCookies(webBrowser1.Url.ToString()),
};
[DllImport("wininet.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern bool InternetGetCookieEx(string pchURL, string pchCookieName, StringBuilder pchCookieData, ref System.UInt32 pcchCookieData, int dwFlags, IntPtr lpReserved);
[DllImport("wininet.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern int InternetSetCookieEx(string lpszURL, string lpszCookieName, string lpszCookieData, int dwFlags, IntPtr dwReserved);
#region 获取cookies
private static string GetCookies(string url)
{
uint datasize = 256;
StringBuilder cookieData = new StringBuilder((int)datasize);
if (!InternetGetCookieEx(url, null, cookieData, ref datasize, 0x2000, IntPtr.Zero))
{
if (datasize < 0)
return null;
cookieData = new StringBuilder((int)datasize);
if (!InternetGetCookieEx(url, null, cookieData, ref datasize, 0x00002000, IntPtr.Zero))
return null;
}
return cookieData.ToString();
}
#endregion
我通过这个测试之后,发现怎么也留不了言!我确定已经提交过了,总是提示:{"en":"ERR_USER_OVERPOST_TWEET","zh":"\u60a8\u63d0\u4ea4\u7684\u901f\u5ea6\u592a\u5feb\u4e86\uff0c\u8bf7\u7a0d\u5019\u53d1\u8868\uff01","captcha_expire":21000}
我用FIddlER4都都无法获取到这个框架发送的数据呢 |
|