PHP调用二维码生成接口示例:
<?php $text = 'test'; $url = 'https://api.ip138.com/qrcode/?text='.$text; $header = array('token:00d5cb1fac5dc5cbfe2ff218292a2dfd33'); echo getData($url,$header); function getData($url,$header){ $ch = curl_init(); curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_1_1); curl_setopt($ch,CURLOPT_HTTPHEADER,$header); curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,3); $handles = curl_exec($ch); curl_close($ch); return $handles; } ?>
<?php //js引入页面 callback jsonp回调地址 $text = 'test'; $mid = 35553; $oid = 2; $token = '00d5cb1fac5dc5cbfe2ff218292a2dfd33'; $sign = md5("text=".$text."&token=".$token); $url = 'https://api.ip138.com/qrcode/'; //以下是js引入代码 /*** /*<script type="text/javascript" src="<?php echo $url.'?text='.$text.'&oid='.$oid.'&mid='.$mid.'&sign='.$sign;?>"></script> **/ ?>