Curl request and binary picture processing

Source: Internet
Author: User
Tags ssl certificate

1 2$ch=Curl_init (); 3 curl_setopt ($ch, Curlopt_url,$url.$token); 4 curl_setopt ($ch, Curlopt_ssl_verifypeer, 0);//Skipping SSL certificate checking5 curl_setopt ($ch, Curlopt_ssl_verifyhost, 2);//Check if the certificate has (common name) field and determine if the current domain name matches the certificate6 curl_setopt ($ch, Curlopt_header,TRUE);//that means you need to response head without head, everything is content .7 curl_setopt ($ch, Curlopt_post, 1);//POST Request8 curl_setopt ($ch, Curlopt_postfields, Json_encode ($data)); 9 curl_setopt ($ch, Curlopt_returntransfer, 1);//do not output the obtained content10 11$response= Curl_exec ($ch);12 13if(Curl_getinfo ($ch, curlinfo_http_code) = = ' 200 ') {14 15//when there's head, you need to split the head and the content .16List($header,$data) =Explode("\r\n\r\n",$response, 2);17      }Curl_close ($ch);
1  $tempfile= @fopen($_server[' Document_root ']. ' /authok.png ', "RB");2 $bin=fread($tempfile, 2);//read-only 2 bytes3 $strInfo= @Unpack("C2chars",$bin);4         $typeCode=intval($strInfo[' Chars1 '].$strInfo[' Chars2 ']);5         $fileType= ' ';6         Switch($typeCode){//6677:bmp 255216:jpg 7173:gif 13780:png 7790:exe 8297:rar 8075:zip tar:109121 7z:55122 gz 311397              Case' 255216 ':8                 $fileType= ' jpg ';9                  Break;Ten              Case' 7173 ': One                 $fileType= ' gif '; A                  Break; -              Case' 13780 ': -                 $fileType= ' png '; the                  Break; -             default: -                 $fileType= ' Unknown '; -         } +         Echo $fileType;

Curl request and binary picture processing

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.