public void Evaluate(int SpreadMax) { client_out.SliceCount = 1; succeed_out.SliceCount = 1; if (authorize_in.SliceCount > 0 && authorize_in[0] && app_key_in[0].Length > 0 && app_secret_in[0].Length > 0 && callback_url_in[0].Length > 0) { //weiboClient = new SinaWeiboClient("1402038860", "62e1ddd4f6bc33077c796d5129047ca2", "http://qcyn.sina.com.cn"); SinaWeiboClient weiboClient = new SinaWeiboClient(app_key_in[0], app_secret_in[0], callback_url_in[0]); AuthenticationForm form = weiboClient.GetAuthenticationForm(); if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK) { client_out[0] = weiboClient; succeed_out[0] = true; FLogger.Log(LogType.Debug, "Authorize Succeed"); FLogger.Log(LogType.Debug, weiboClient.AccessToken); } else { client_out[0] = null; succeed_out[0] = false; FLogger.Log(LogType.Debug, "Authorize Failed"); } } }
public SinaWeiboTest() { console.info("等待用户授权..."); var openAuth = new SinaWeiboClient("1402038860", "62e1ddd4f6bc33077c796d5129047ca2", "http://qcyn.sina.com.cn"); var form = openAuth.GetAuthenticationForm(); if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK) { console.info("用户授权成功!"); console.data("AccessToken={0}", openAuth.AccessToken); StartTest(openAuth); } else { console.error("用户授权失败!"); } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //请自行修改appKey,appSecret和回调地址。winform的回调地址可以是一个随便可以访问的地址,貌似不可以访问的地址也是可以的,只要URL中带着Code就行 var client = new SinaWeiboClient("4257120060", "ad556a1a628e118e14ff19f00f1266c5", "http://www.zfcode.com"); //NetDimension.OpenAuth.Winform封装的一个登录窗口,主要远离就是个WebBrowser控件,然后在该控件的导航事件里面监测Url是不是带有Code,如果有就调用GetAccessTokenByCode var authForm = client.GetAuthenticationForm(); authForm.StartPosition = FormStartPosition.CenterScreen; //authForm.Icon = Properties.Resources.icon_form; if (authForm.ShowDialog() == DialogResult.OK) { Application.Run(new Form1(client)); } // Application.Run(new Form1()); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //请自行修改appKey,appSecret和回调地址。winform的回调地址可以是一个随便可以访问的地址,貌似不可以访问的地址也是可以的,只要URL中带着Code就行 var client = new SinaWeiboClient("1402038860", "62e1ddd4f6bc33077c796d5129047ca2", "http://qcyn.sina.com.cn"); //NetDimension.OpenAuth.Winform封装的一个登录窗口,主要远离就是个WebBrowser控件,然后在该控件的导航事件里面监测Url是不是带有Code,如果有就调用GetAccessTokenByCode var authForm = client.GetAuthenticationForm(); authForm.StartPosition = FormStartPosition.CenterScreen; authForm.Icon = Properties.Resources.icon_form; if (authForm.ShowDialog() == DialogResult.OK) { Application.Run(new Form1(client)); } }