How to upgrade air beta2 to air beta3 (2) URLRequest

Source: Internet
Author: User
Tags http authentication

We know that some websites are authenticated by the Basic Authentication of Copper Drum even HTTP. For example, api.fanhou.com

During Air beta2, an air client for food was collected and can run normally. However, after I upgraded to beta3 yesterday, it failed to run normally. The error is as follows:

Urlr. setlogincredentials (loginname, loginpass); this method cannot be found.

This method is removed after the new doc document is queried and the upgrade is confirmed. The question is how to find a new solution, so I searched for some HTTP Authentication principles on the Internet, as shown below:

Basic authentication is the earliest and most compatible scheme specified in HTTP. Unfortunately, it is also the most insecure scheme because it transmits the user name and password with an explicit code. It requires a usernamepasswordcredentials instance. You can specify the access space on the server or use the default logon information.

But what should I do next? Does air provide a new API to replace this method. So I found a static method in the urlrequestdefaults class in the API.

Setlogincredentialsforhost ()

So I tried to change the error method:

Urlrequestdefaults. setlogincredentialsforhost ("api.fanfou.com", loginname, loginpass );

Compiled successfully and runs normally.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.