PhotobucketNet照片上传

发布于 2025-01-07 13:57:05 字数 457 浏览 1 评论 0原文

我在 PhotobucketNet 用户登录方面遇到问题(我需要用户登录,以便我可以将图片从 HDD 上传到他的 Photobucket 帐户)。

Photobucket photobucket = new Photobucket("myapikey", "myapisecret");
photobucket.LaunchUserLogin();
// the problem happens here
photobucket.RequestUserToken();

如果我调用 RequestUserToken() ,它会立即发生,所以我会因为用户未登录而崩溃,并且用户登录后不会引发任何事件。是否有一些变量(bool 或其他变量)我可以检查用户是否登录 - 也许将其与计时器一起放入循环中? 他们也是知道用户是否取消登录的一种方法吗? 我知道计时器不是一个好的解决方案,所以如果有人有更好的想法,我愿意接受任何建议......

I have a problem with PhotobucketNet user login(I need user to login so I can upload a picture from HDD to his Photobucket account).

Photobucket photobucket = new Photobucket("myapikey", "myapisecret");
photobucket.LaunchUserLogin();
// the problem happens here
photobucket.RequestUserToken();

If I call RequestUserToken() it will happen immediately, so I'll get a crash cause user didn't logged in, and there is no event that's been raised after user logs in. Is there some variable(bool or something else) that I can check to see if user logged in - maybe to put it in a loop with timer?
Also is their a way to know if user canceled logging in?
I know that timer isn't a good solution, so if anyone has anything better as an idea, I'm open for any suggestions...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

醉梦枕江山 2025-01-14 13:57:05

我今天遇到了同样的问题,在寻找解决方案时发现了您的帖子。以下是我设法解决问题的方法:

首先,我获得“用户登录网址”并将其传递到带有 Web 浏览器控件(称为“登录”)的表单。

Service=new Photobucket ("mykey", "mysecret");
string u=Service.GenerateUserLoginUrl ();
Login l=new Login (u);
l.Show ();

接下来,我从这个页面获取了url,

enter image description here

这是登录后的页面。如果 Web 浏览器的 url 是该页面,我会要求 photobucket 类(在我的例子中为 Program.Service)来请求令牌。

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

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
       }
    }
}

现在您只需保存令牌并使用它。

I've encountered the same problem today and i found your post while i was searching for solutions. Here is how i managed to solve the problem:

Firstly, i got the "user login url" and passed it to a form with a web browser control, called "Login".

Service=new Photobucket ("mykey", "mysecret");
string u=Service.GenerateUserLoginUrl ();
Login l=new Login (u);
l.Show ();

Next, I got the url from this page,

enter image description here

which is the page after the login. If the web browser's url is that page, i asked the photobucket class (in my case Program.Service), to request the token.

The code from the Login form is something like this:

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
       }
    }
}

Now you just save the token and use it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文