//ͬ��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.consumerKey, key.consumerSecret, 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.consumerKey, key.consumerSecret, 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; }
public void Sync(IUser user, string text, string picUrl) { if (user == null) return; if (string.IsNullOrEmpty(text) || text.Length > 140) return; IUserWeiboSettingService userWeiboSettingService = new UserWeiboSettingService(); WeiboType type = WeiboType.GetByName("qqweibo"); if (type == null || type.Enable!=1 ) return; UserWeiboSetting setting = userWeiboSettingService.Find(user.Id, type.Id); //用户未绑定微博或用户暂时选择同步 if (setting == null || setting.IsSync == 0) return; if (string.IsNullOrEmpty(setting.AccessToken) || string.IsNullOrEmpty(setting.AccessSecret)) return; QQWeibo.OauthKey oauthKey = new QQWeibo.OauthKey(type.AppKey,type.AppSecret,setting.AccessToken,setting.AccessSecret); T twit = new T(oauthKey, "json"); //暂时用127.0.0.1处理,因为这里得没办法得到ip值 string ip = "127.0.0.1"; string result; try { if (string.IsNullOrEmpty(picUrl)) { result= twit.add(text, ip, "", ""); } else { result = twit.add_pic(text, ip, "", "", picUrl); } } catch (Exception ex) { log.Error(ex.Message); } log.Info("同步成功"); }
/// <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 processQQWeibo() { WeiboType type = WeiboType.GetByName("qqweibo"); if (type == null) return; OauthKey key = new OauthKey(type.AppKey, type.AppSecret); bool success = false; try { string callback = ctx.url.SiteUrl.TrimEnd('/') + to(new UserWeiboSettingController().QQWeiboCallback); success = key.GetRequestToken(callback); } catch (Exception ex) { logger.Error(ex.Message); } if (success) { ctx.web.SessionSet("qqweibo", key); redirectUrl(key.GetOAuthUrl()); } else { echoRedirect("操作失败,请重试"); } }
/// <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="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="@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) { }
private void redirectQQWeiboRegister(WeiboType type, OauthKey key,string screenName,string profileImg) { UserWeiboSetting setting = new UserWeiboSetting { AccessToken = key.tokenKey, AccessSecret = key.tokenSecret, IsSync = 1, WeiboType = type.Id, AppId = ctx.owner.Id, BindTime = DateTime.Now, WeiboName = type.Name, WeiboUid = key.WeiboName }; WeiboSession session = new WeiboSession(setting, screenName, type.FriendName, profileImg); ctx.web.SessionSet(WeiboSession.SessionName, session); redirectUrl(to(new WeiboRegisterController().Bind) + "?type=" + setting.WeiboName); }
private void processQQWeibo(WeiboType type) { OauthKey key = new OauthKey(type.AppKey, type.AppSecret); bool success = false; try { string callback = ctx.url.SiteUrl.TrimEnd('/') + to(QQWeiboCallback); success = key.GetRequestToken(callback); } catch (Exception ex) { log.Error(ex.Message); } if (success) { ctx.web.SessionSet("qqweibo", key); redirectUrl(key.GetOAuthUrl()); } else { echoRedirect("操作失败,请重试"); } }
/// <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="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="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) { }