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