在线测试

在线测试

在线测试


  

function myget($url){

	    $ch = curl_init($url);
		
		curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
		
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  
		curl_setopt($ch, CURLOPT_HEADER , true); 
		
		$data = curl_exec($ch);
		$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
		curl_close($ch);
		return $data;
}
function post($url,$fields){
		$ch = curl_init($url);
		curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // 对认证证书来源的检查
		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); // 从证书中检查SSL加密算法是否存在
		curl_setopt($ch, CURLOPT_HEADER , true);
		curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
		$data = curl_exec($ch);
		$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);

		curl_close($ch);
		return $data;
}



$data = [
   'dati_type'=>   8091,//答题类型
   'acc_str'=>   'xxxxxxxxxxxx',//登录账号查询自己的答题密码串
   'extra_str'=>   '题目是。。。。。',//以便答题人员能够理解答题
   'zz'=>   '',//作者帐号(给予返利)
   'pri'=>   9,//优先级
   'timeout'=>   70,//答题事件不要太小,否则容易超时而不能返回结果
   'pic'=>   base64_encode(file_get_contents("/sdcard/img.png")),//可以使用base64 编码图片数据

];

$res  = post('http://dt1.hyocr.com:8080/uploadpic.php ',$data);

if(substr($res,0,1)=="#"){
	//答题错误,填写上传题目错误的逻辑  可能是不符合格式
	echo $res ; 
}else{
	$id = $res;
	while(true){
		
		sleep(5);
		
		$res2= myget("http://dt1.hyocr.com:8080/Query.php?sid=" .$id);
		
		if(!empty($res2)){
			if(substr($res2,0,1)=="#"){
				  
				echo $res2 ;
				//出错的逻辑
			}else{
				//获取到了正确答案
			}
			break;
		}
	}
}




说明:xxxxxxxxxxxxxxx替换成密码串 提交成功后会返回一组字符串 直接用这个字符串每1秒循环get提交到http://dt1.hyocr.com:8080/Query.php 即可 一直取到答案为止 取到答案判断 一下答案的第一个字符串 如果为“#” 即为报错了 如果不是#开头 即为返回的答案