What should I do if I use PHP for HTTP authentication?

Source: Internet
Author: User
Tags http authentication
You can use PHP to enable HTTP verification for the image httpauthentication www.vividchanelhandbags.comimages20000665.jpg. Write a function to download the image. Know how to verify the account and password test123789. How can I pass the account password through the function? Experts Help ------ solution ------------------ what is garbled? Use PHP for HTTP authentication
Http://www.vividchanelhandbags.com/images/20000665.jpgcan be opened only after httpverification. Write a function to download the image. Know the verified account and password
How does test 123789 do this. How can I pass the account password through the function? Help

------ Solution --------------------
Is this garbled? Haha
PHP code
$ Url = "http://www.vividchanelhandbags.com/images/20000665.jpg"; $ ch = curl_init ($ url); $ useragent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1 )"; $ header = array ('Accept-Language: zh-cn', 'connection: Keep-Alive ', 'cache-Control: no-cache '); // HEADER information curl_setopt ($ ch, CURLOPT_HTTPHEADER, $ header); // USER_AGENT curl_setopt ($ ch, CURLOPT_USERAGENT, $ useragent); curl_setopt ($ ch, CURLOPT_USERPWD, "test: 123789 "); $ response = curl_exec ($ ch); // you get the binary content of the image. to display the image, you must tell the browser, what is the content format header ("content-type: image/jpg"); echo $ response;
------ Solution --------------------
PHP code
     

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.