//异步http请求 public bool AsyncRequest(string url, string httpMethod, OauthKey key, List <Parameter> listParam, List <Parameter> listFile, AsyncRequestCallback callback, out int callbkey) { Oauth oauth = new Oauth(); string queryString = null; string oauthUrl = oauth.GetOauthUrl(url, httpMethod, key.customKey, key.customSecret, key.tokenKey, key.tokenSecret, key.verify, key.callbackUrl, listParam, out queryString); AsyncHttp http = new AsyncHttp(); callbkey = GetKey(); CallbackInfo callbackInfo = new CallbackInfo(); callbackInfo.key = callbkey; callbackInfo.callback = callback; asyncRquestMap.Add(http, callbackInfo); bool bResult = false; if (httpMethod == "GET") { bResult = http.HttpGet(oauthUrl, queryString, new AsyncHttpCallback(HttpCallback)); } else if ((listFile == null) || (listFile.Count == 0)) { bResult = http.HttpPost(oauthUrl, queryString, new AsyncHttpCallback(HttpCallback)); } else { bResult = http.HttpPostWithFile(oauthUrl, queryString, listFile, new AsyncHttpCallback(HttpCallback)); } if (!bResult) { asyncRquestMap.Remove(http); } return(bResult); }
//ͬ��http���� public string SyncRequest(string url, string httpMethod, OauthKey key, List<Parameter> listParam, List<Parameter> listFile) { Oauth oauth = new Oauth(); string queryString = null; string oauthUrl = oauth.GetOauthUrl(url, httpMethod, key.customKey, key.customSecret, key.tokenKey, key.tokenSecret, key.verify, key.callbackUrl, listParam, out queryString); SyncHttp http = new SyncHttp(); if (httpMethod == "GET") { return http.HttpGet(oauthUrl, queryString); } else if ((listFile == null) || (listFile.Count == 0)) { return http.HttpPost(oauthUrl, queryString); } else { return http.HttpPostWithFile(oauthUrl, queryString, listFile); } }
//�첽http���� public bool AsyncRequest(string url, string httpMethod, OauthKey key, List<Parameter> listParam, List<Parameter> listFile, AsyncRequestCallback callback, out int callbkey) { Oauth oauth = new Oauth(); string queryString = null; string oauthUrl = oauth.GetOauthUrl(url, httpMethod, key.customKey, key.customSecret, key.tokenKey, key.tokenSecret, key.verify, key.callbackUrl, listParam, out queryString); AsyncHttp http = new AsyncHttp(); callbkey = GetKey(); CallbackInfo callbackInfo = new CallbackInfo(); callbackInfo.key = callbkey; callbackInfo.callback = callback; asyncRquestMap.Add(http, callbackInfo); bool bResult = false; if (httpMethod == "GET") { bResult = http.HttpGet(oauthUrl, queryString, new AsyncHttpCallback(HttpCallback)); } else if ((listFile == null) || (listFile.Count == 0)) { bResult = http.HttpPost(oauthUrl, queryString, new AsyncHttpCallback(HttpCallback)); } else { bResult = http.HttpPostWithFile(oauthUrl, queryString, listFile, new AsyncHttpCallback(HttpCallback)); } if (!bResult) { asyncRquestMap.Remove(http); } return bResult; }
//同步http请求 public string SyncRequest(string url, string httpMethod, OauthKey key, List <Parameter> listParam, List <Parameter> listFile) { Oauth oauth = new Oauth(); string queryString = null; string oauthUrl = oauth.GetOauthUrl(url, httpMethod, key.customKey, key.customSecret, key.tokenKey, key.tokenSecret, key.verify, key.callbackUrl, listParam, out queryString); SyncHttp http = new SyncHttp(); if (httpMethod == "GET") { return(http.HttpGet(oauthUrl, queryString)); } else if ((listFile == null) || (listFile.Count == 0)) { return(http.HttpPost(oauthUrl, queryString)); } else { return(http.HttpPostWithFile(oauthUrl, queryString, listFile)); } }
private void buttonSend_Click(object sender, EventArgs e) { textOutput.Text = ""; List<Parameter> parameters = new List<Parameter>(); OauthKey oauthKey = new OauthKey(); oauthKey.customKey = appKey; oauthKey.customSecret = appSecret; oauthKey.tokenKey = accessKey; oauthKey.tokenSecret = accessSecret; bool getMethod = comboMethod.SelectedIndex == 0 ? true : false; /*http���������name������*/ List<string> arryName = new List<string>(); /*http���������value������*/ List<string> arryValue = new List<string>(); listViewHeader.GetColumnItem(1, arryName); listViewHeader.GetColumnItem(2, arryValue); /*����listview�õ���value����utf8����,�������������б�*/ string ret; UTF8Encoding utf8 = new UTF8Encoding(); if (0 == comboMethod.SelectedIndex) { statuses st = new statuses(oauthKey, "json"); ret = st.home_timeline(Convert.ToInt32(arryValue[0]), Convert.ToInt32(arryValue[1]), Convert.ToInt32(arryValue[2])); } else { t twit = new t(oauthKey, "json"); ret = twit.add_pic(utf8.GetString(utf8.GetBytes(arryValue[0])), utf8.GetString(utf8.GetBytes(arryValue[1])), utf8.GetString(utf8.GetBytes(arryValue[2])), utf8.GetString(utf8.GetBytes(arryValue[3])), utf8.GetString(utf8.GetBytes(arryValue[4])) ); // ret = twit.add_pic("xxxx","127.0.0.1","","","E:\abc.jpg"); } textOutput.Text = ret; }
/// <summary>构造函数 /// <see cref="friends"/> class. /// </summary> /// <param name="okey">The okey.</param> /// <param name="format">The format.</param> /// <remarks></remarks> public friends(OauthKey okey, string format) : base(okey, format) { }
/// <summary> /// 构造函数 <see cref="user"/> class. /// </summary> /// <param name="okey">The okey.</param> /// <param name="format">The format.</param> /// <remarks></remarks> public user(OauthKey okey, string format) : base(okey, format) { }
/// <summary> 私信相关 /// 构造函数 <see cref="@private"/> class. /// </summary> /// <param name="okey">The okey.</param> /// <param name="format">The format.</param> /// <remarks></remarks> public @private(OauthKey okey, string format) : base(okey, format) { }
/// <summary> 搜索相关 需要 合作伙伴权限 /// 构造函数 <see cref="search"/> class. /// </summary> /// <param name="okey">The okey.</param> /// <param name="format">The format.</param> /// <remarks></remarks> public search(OauthKey okey, string format) : base(okey, format) { }
/// <summary> /// 构造函数 <see cref="tag"/> class. /// </summary> /// <param name="okey">The okey.</param> /// <param name="format">The format.</param> /// <remarks></remarks> public tag(OauthKey okey, string format) : base(okey, format) { }
private void Send() { string strRet = ""; List<QWeiboSDK.Parameter> parameters = new List<QWeiboSDK.Parameter>(); OauthKey oauthKey = new OauthKey(); oauthKey.customKey = strAppKey; oauthKey.customSecret = strAppSecret; oauthKey.tokenKey = Session["accessToken"].ToString(); oauthKey.tokenSecret = Session["accessSecret"].ToString(); }
/// <summary>数据更新相关 /// 构造函数 <see cref="info"/> class. /// </summary> /// <param name="okey">The okey.</param> /// <param name="format">The format.</param> /// <remarks></remarks> public info(OauthKey okey, string format) : base(okey, format) { }
public QWeiboApiBase(OauthKey authkey, string format) { this.oauthkey = authkey; this.format = format; }
/// <summary> 时间线相关 /// 构造函数<see cref="statuses"/> class. /// </summary> /// <param name="okey">The okey.</param> /// <param name="format">The format.</param> /// <remarks></remarks> public statuses(OauthKey okey, string format) : base(okey, format) { }
/// <summary> 数据收藏类的 构造函数 /// <see cref="fav"/> class. /// </summary> /// <param name="okey">The okey.</param> /// <param name="format">The format.</param> /// <remarks></remarks> public fav(OauthKey okey, string format) : base(okey, format) { }
private bool GetAccessToken(string customerKey, string customerSecret, string requestToken, string requestTokenSecrect, string verify) { string url = "https://open.t.qq.com/cgi-bin/access_token"; List<QWeiboSDK.Parameter> parameters = new List<QWeiboSDK.Parameter>(); OauthKey oauthKey = new OauthKey(); oauthKey.customKey = customerKey; oauthKey.customSecret = customerSecret; oauthKey.tokenKey = requestToken; oauthKey.tokenSecret = requestTokenSecrect; oauthKey.verify = verify; QWeiboRequest request = new QWeiboRequest(); return ParseToken(request.SyncRequest(url, "GET", oauthKey, parameters, null)); }
private bool GetRequestToken(string customerKey, string customerSecret) { string url = "https://open.t.qq.com/cgi-bin/request_token"; List<QWeiboSDK.Parameter> parameters = new List<QWeiboSDK.Parameter>(); OauthKey oauthKey = new OauthKey(); oauthKey.customKey = customerKey; oauthKey.customSecret = customerSecret; oauthKey.callbackUrl = ConfigurationManager.AppSettings["CallbackUrl_QQ"]; //"http://localhost:20595"; QWeiboRequest request = new QWeiboRequest(); return ParseToken(request.SyncRequest(url, "GET", oauthKey, parameters, null)); }
private bool GetRequestToken(string customKey, string customSecret) { string url = "https://open.t.qq.com/cgi-bin/request_token"; List<Parameter> parameters = new List<Parameter>(); OauthKey oauthKey = new OauthKey(); oauthKey.customKey = customKey; oauthKey.customSecret = customSecret; oauthKey.callbackUrl = "http://www.qq.com"; QWeiboRequest request = new QWeiboRequest(); return ParseToken(request.SyncRequest(url, "GET", oauthKey, parameters, null)); }