php二维码生成

来源:互联网 发布:自然语言处理常见算法 编辑:程序博客网 时间:2024/05/16 17:01
/*
     * 生成二维码
     * curl 二维码跳转链接带上参数
     */
    public function erweima_function($curl){
        $url = 'http://qr.59na.com/';
        $urlpost = "http://qr.59na.com/index.php?m=Qrcode&a=create";
        $post = "t=".$curl."&f=#000000&b=#FFFFFF&pt=#000000&inpt=#000000&s=1&level=L";
        $jsonstr = request_by_curl($urlpost,$post);
        return $url.json_decode($jsonstr);
    }


    // 二维码生成地址,post请求
    function request_by_curl($remote_server, $post_string) {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $remote_server);
        curl_setopt($ch, CURLOPT_POSTFIELDS,$post_string);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_USERAGENT, "qianyunlai.com's CURL Example beta");
        $data = curl_exec($ch);
        curl_close($ch);
        return $data;

    }


//调用方式

$url = erweima_function('http://www.xxx.com?act=xxx&id20');
// url 图片绝对路径
header('Content-type: image/jpeg');
$file = file_get_contents($url);
echo $file;

原创粉丝点击