C# PhotobucketNet照片上传

C# PhotobucketNet照片上传,c#,.net,upload,photobucket,C#,.net,Upload,Photobucket,我有一个问题与PhotobucketNet用户登录我需要用户登录,以便我可以上传一张图片从硬盘到他的Photobucket帐户 Photobucket photobucket = new Photobucket("myapikey", "myapisecret"); photobucket.LaunchUserLogin(); // the problem happens here photobucket.RequestUserToken(); 如果我调用RequestUserToken,它将

我有一个问题与PhotobucketNet用户登录我需要用户登录,以便我可以上传一张图片从硬盘到他的Photobucket帐户

Photobucket photobucket = new Photobucket("myapikey", "myapisecret");
photobucket.LaunchUserLogin();
// the problem happens here
photobucket.RequestUserToken();
如果我调用RequestUserToken,它将立即发生,因此我将得到一个崩溃,因为用户没有登录,并且在用户登录后没有引发任何事件。是否有一些variablebool或其他东西,我可以检查用户是否登录-也许可以将其与计时器放在一个循环中? 这也是一种知道用户是否取消登录的方法吗?
我知道计时器不是一个好的解决方案,所以如果有人有更好的想法,我愿意接受任何建议…

我今天遇到了同样的问题,我在搜索解决方案时找到了你的帖子。以下是我如何解决问题的:

首先,我获得了用户登录url,并将其传递给一个带有web浏览器控件的表单,称为login

Service=new Photobucket ("mykey", "mysecret");
string u=Service.GenerateUserLoginUrl ();
Login l=new Login (u);
l.Show ();
接下来,我从这个页面得到了url

这是登录后的页面。如果web浏览器的url就是那个页面,我在case Program.Service中请求photobucket类请求令牌

登录表单中的代码如下所示:

public Login (string url)
{
    InitializeComponent ();
    webBrowser1.Navigate (url);
    webBrowser1.DocumentCompleted+=delegate
    {
    if (webBrowser1.Url.ToString ()=="http://photobucket.com/apilogin/done")
       {
             PhotobucketNet.UserToken t=Program.Service.RequestUserToken ();
             //save the token
       }
    }
}
现在您只需保存令牌并使用它