{"id":954,"date":"2014-01-26T06:31:15","date_gmt":"2014-01-25T14:31:15","guid":{"rendered":"http:\/\/www.yclimw.com\/?p=954"},"modified":"2021-05-31T14:08:14","modified_gmt":"2021-05-31T06:08:14","slug":"561c4d71366aed05190e91b9599268a6","status":"publish","type":"post","link":"https:\/\/www.yclimw.com\/?p=954","title":{"rendered":"PHP\u751f\u6210QR\u4e8c\u7ef4\u7801\u7684\u51e0\u79cd\u65b9\u6cd5"},"content":{"rendered":"<h2>\u76f4\u63a5\u8c03\u7528Google Chart API\u63a5\u53e3<\/h2>\n<div>\u8c03\u7528\u6f14\u793a\uff1a<\/div>\n<div><\/div>\n<div>\n<div style=\"border: 1px solid black; margin-left: auto; margin-right: auto; padding: 3px; font-family: 'Courier New'; font-size: 12px;\">\n<div>\n<div>&lt;form method=&#8221;post&#8221; action=&#8221;googleqr.php&#8221;&gt;<\/div>\n<div>&lt;input type=&#8221;text&#8221; name=&#8221;urlToEncode&#8221; value=&#8221;&#8221; \/&gt;<\/div>\n<div>&lt;input type=&#8221;submit&#8221; name=&#8221;submit&#8221; value=&#8221;\u751f\u6210&#8221; \/&gt;<\/div>\n<div>&lt;\/form&gt;<\/div>\n<\/div>\n<div><span style=\"color: #333399;\">&lt;<\/span><span style=\"color: #333399;\">?<\/span>php<br \/>\n<span style=\"color: #008000;\">\/\/google API<\/span><br \/>\n<span style=\"color: #0000ff;\"><b>function<\/b><\/span> generateQRfromGoogle($chl,$widhtHeight <span style=\"color: #333399;\">=<\/span><span style=\"color: #ff00bf;\">&#8216;150&#8217;<\/span>,$EC_level<span style=\"color: #333399;\">=<\/span><span style=\"color: #ff00bf;\">&#8216;L&#8217;<\/span>,$margin<span style=\"color: #333399;\">=<\/span><span style=\"color: #ff00bf;\">&#8216;0&#8217;<\/span>)<br \/>\n{<br \/>\n$url <span style=\"color: #333399;\">=<\/span> urlencode($url);<br \/>\n<span style=\"color: #0000ff;\"><b>echo<\/b><\/span> <span style=\"color: #ff00bf;\">&#8216;&lt;img src=&#8221;http:\/\/chart.apis.google.com\/chart?chs=&#8217;<\/span>.$widhtHeight.<span style=\"color: #ff00bf;\">&#8216;x&#8217;<\/span>.$widhtHeight.<span style=\"color: #ff00bf;\">&#8216;&amp;cht=qr&amp;chld=&#8217;<\/span>.$EC_level.<span style=\"color: #ff00bf;\">&#8216;|&#8217;<\/span>.$margin.<span style=\"color: #ff00bf;\">&#8216;&amp;chl=&#8217;<\/span>.$chl.<span style=\"color: #ff00bf;\">&#8216;&#8221; alt=&#8221;QR code&#8221; widhtHeight=&#8221;&#8216;<\/span>.$size.<span style=\"color: #ff00bf;\">&#8216;&#8221; widhtHeight=&#8221;&#8216;<\/span>.$size.<span style=\"color: #ff00bf;\">&#8216;&#8221;\/&gt;&#8217;<\/span>;<br \/>\n}<span style=\"color: #0000ff;\"><b>if<\/b><\/span>(<span style=\"color: #0000ff;\"><b>isset<\/b><\/span>($_POST[<span style=\"color: #ff00bf;\">&#8216;urlToEncode&#8217;<\/span>])){<br \/>\ngenerateQRfromGoogle($_POST[<span style=\"color: #ff00bf;\">&#8216;urlToEncode&#8217;<\/span>]);<br \/>\n<span style=\"color: #0000ff;\"><b>echo<\/b><\/span> <span style=\"color: #ff00bf;\">&#8220;&lt;br \/&gt;&#8221;<\/span>;<br \/>\n}<span style=\"color: #0000ff;\"><b>else<\/b><\/span>{<br \/>\n<span style=\"color: #0000ff;\"><b>echo<\/b><\/span> <span style=\"color: #ff00bf;\">&#8220;\u8bf7\u8f93\u5165\u8981\u751f\u6210\u4e8c\u7ef4\u7801\u7684\u5185\u5bb9&lt;br \/&gt;&#8221;<\/span>;<br \/>\n}<span style=\"color: #333399;\">?<\/span><span style=\"color: #333399;\">&gt;<\/span><\/div>\n<\/div>\n<\/div>\n<div><\/div>\n<div>\u6548\u679c\u56fe\uff1a<\/div>\n<div><img decoding=\"async\" src=\"https:\/\/www.yclimw.com\/wp-content\/uploads\/2014\/01\/wpid-3a28d01d948de66ed9a6e61866a1b998_bb5c2502-61b3-4b83-b46a-d1ed225d78661.png\" alt=\"\" \/><\/div>\n<div><\/div>\n<div><a href=\"http:\/\/blog.yclimw.com\/googleqr.php\">\u70b9\u51fb\u5c1d\u8bd5\u81ea\u5df1\u751f\u6210<\/a><\/div>\n<div><\/div>\n<div>Google Chart API \u66f4\u591a\u4fe1\u606f\uff1a<a href=\"https:\/\/developers.google.com\/chart\/?csw=1\">https:\/\/developers.google.com\/chart\/?csw=1<\/a><\/div>\n<h2>\u4f7f\u7528\u5f00\u6e90\u7c7b\u5e93\u751f\u6210\u4e8c\u7ef4\u7801\u2014\u2014PHP QR Code<\/h2>\n<div><span style=\"font-family: \u5b8b\u4f53;\">PHP QR Code \u662f\u4e00\u4e2a\u751f\u6210QR\u7801\u3001\u4e8c\u7ef4\u6761\u5f62\u7801\u7684\u5f00\u6e90(LGPL)\u5e93\u3002\u5b83\u57fa\u4e8e<span style=\"font-size: medium; line-height: normal;\">libqrencode C\u5e93\uff0c\u63d0\u4f9b\u4e86\u751f\u6210QR\u6761\u7801\u56fe\u50cf\uff08<\/span><\/span><span style=\"font-size: medium;\"><span style=\"line-height: normal;\">PNG, JPEG thanks to GD2<\/span><\/span><span style=\"font-size: medium; line-height: normal;\">\uff09\u7684API\u63a5\u53e3\u3002\u4e0d\u4f9d\u8d56\u5176\u4ed6\u6269\u5c55\uff08\u4e0d\u5305\u62ecGD2\uff09\uff0c\u7eaf\u7cb9\u7528PHP\u5b9e\u73b0QR\u6761\u7801\u7684\u751f\u6210\u3002<\/span><\/div>\n<div><\/div>\n<div><span style=\"font-family: \u5b8b\u4f53; font-size: medium;\"><span style=\"line-height: normal;\">\u9879\u76ee\u5b98\u7f51\uff1a<\/span><\/span><a style=\"font-size: 10.5pt; background-color: #ffffff; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline; color: #743399; font-family: \u5fae\u8f6f\u96c5\u9ed1, \u9ed1\u4f53, \u5b8b\u4f53; line-height: 18px;\" href=\"http:\/\/blog.galois21.com\/privacy\/Jump_ExternalUrl.php?url=http:\/\/phpqrcode.sourceforge.net\/\" target=\"_blank\" rel=\"noopener\">http:\/\/phpqrcode.sourceforge.net\/<\/a><\/div>\n<div><\/div>\n<div><span style=\"font-family: \u5b8b\u4f53; font-size: medium;\"><span style=\"line-height: normal;\">\u4e0b\u8f7d\u5730\u5740\uff1a<\/span><\/span><a style=\"font-size: 10.5pt; background-color: #ffffff; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline; color: #743399; font-family: \u5fae\u8f6f\u96c5\u9ed1, \u9ed1\u4f53, \u5b8b\u4f53; line-height: 18px;\" href=\"http:\/\/blog.galois21.com\/privacy\/Jump_ExternalUrl.php?url=http:\/\/sourceforge.net\/projects\/phpqrcode\/\" target=\"_blank\" rel=\"noopener\">http:\/\/sourceforge.net\/projects\/phpqrcode\/<\/a><\/div>\n<div><\/div>\n<div>\u4e91\u76d8\u5171\u4eab\u5730\u5740\uff08\u5907\u7528\uff09\uff1a<a href=\"http:\/\/pan.baidu.com\/s\/1o6Bd28y\">http:\/\/pan.baidu.com\/s\/1o6Bd28y<\/a><\/div>\n<div><\/div>\n<div>\u8c03\u7528\u6f14\u793a\uff1a<\/div>\n<div><\/div>\n<div><!--StartFragment--><\/p>\n<div><code style=\"border: 0px; margin: 0px; padding: 0px; vertical-align: baseline; font-family: \u5fae\u8f6f\u96c5\u9ed1, \u9ed1\u4f53, \u5b8b\u4f53; font-size: 13px;\"><\/code><\/p>\n<div style=\"border: 1px solid black; margin-left: auto; margin-right: auto; padding: 3px; font-family: 'Courier New'; font-size: 12px;\">\n<div><span style=\"color: #333399;\">&lt;<\/span><span style=\"color: #333399;\">?<\/span>php<br \/>\n<span style=\"color: #0000ff;\"><b>include<\/b><\/span>(<span style=\"color: #ff00bf;\">&#8216;.\/phpqrcode\/phpqrcode.php&#8217;<\/span>); <span style=\"color: #008000;\">\/\/\u52a0\u8f7d\u7c7b\u5e93<\/span><br \/>\n$data<span style=\"color: #333399;\">=<\/span><span style=\"color: #ff00bf;\">&#8216;https:\/\/www.yclimw.com&#8217;<\/span>; <span style=\"color: #008000;\">\/\/ \u8981\u751f\u6210\u4e8c\u7ef4\u7801\u6570\u636e\u00a0<\/span><br \/>\n$errorCorrectionLevel<span style=\"color: #333399;\">=<\/span><span style=\"color: #ff00bf;\">&#8216;L&#8217;<\/span>;<span style=\"color: #008000;\">\/\/ \u7ea0\u9519\u7ea7\u522b\uff1aL\u3001M\u3001Q\u3001H\u00a0<\/span><br \/>\n$matrixPointSize <span style=\"color: #333399;\">=<\/span> <span style=\"color: #6e00aa;\">4<\/span>;<span style=\"color: #008000;\">\/\/ \u70b9\u7684\u5927\u5c0f\uff1a1\u523010\u00a0<\/span><br \/>\n<span style=\"color: #008000;\">\/\/ \u751f\u6210\u7684\u6587\u4ef6\u540d\u00a0<\/span><br \/>\n$filename <span style=\"color: #333399;\">=<\/span> $errorCorrectionLevel.<span style=\"color: #ff00bf;\">&#8220;_&#8221;<\/span>.$matrixPointSize.<span style=\"color: #ff00bf;\">&#8216;.png&#8217;<\/span>;<br \/>\nQRcode<span style=\"color: #333399;\">:<\/span><span style=\"color: #333399;\">:<\/span>png($data,$filename,$errorCorrectionLevel,$matrixPointSize,<span style=\"color: #6e00aa;\">2<\/span>);<br \/>\n<span style=\"color: #0000ff;\"><b>echo<\/b><\/span> <span style=\"color: #ff00bf;\">&#8220;&lt;img src=&#8221;<\/span>.$filename.<span style=\"color: #ff00bf;\">&#8221; \/&gt;&#8221;<\/span>;<br \/>\n<span style=\"color: #333399;\">?<\/span><span style=\"color: #333399;\">&gt;<\/span><\/div>\n<\/div>\n<p><small><\/small><small>\u00a0<\/small><\/p>\n<\/div>\n<div><a href=\"http:\/\/blog.yclimw.com\/qrdemo.php\">\u67e5\u770b\u6548\u679c<\/a><\/div>\n<p><!--EndFragment--><\/p>\n<\/div>\n<h2>\u5ba2\u6237\u7aef\u751f\u6210\u5de5\u5177\u2014\u2014Psytec QR Code Editor<\/h2>\n<div><span style=\"font-family: 'Microsoft YaHei UI'; font-size: 10.5pt; line-height: 1.5;\">\u00a0 \u00a0\u00a0<\/span>Psytec QR Code Editor\u662f\u4e00\u6b3e\u7528\u4e8e\u5728PC\u7aef\u751f\u6210\u4e8c\u7ef4\u7801\u7684\u5de5\u5177\uff0c\u5f53\u7136\u7f51\u4e0a\u8fd8\u6709\u5f88\u591a\u7c7b\u4f3c\u8f6f\u4ef6\uff0c\u53ef\u4ee5\u627e\u5ea6\u5a18\u8981\u3002<\/div>\n<div><\/div>\n<div><img decoding=\"async\" src=\"https:\/\/www.yclimw.com\/wp-content\/uploads\/2014\/01\/wpid-3a28d01d948de66ed9a6e61866a1b998_df51599c-415d-4f39-9ecd-94cae95b37e6.png\" alt=\"\" name=\"\" border=\"0\" \/><\/div>\n<div><\/div>\n<div>Psytec QR Code Editor\u4e0b\u8f7d\u5730\u5740\uff1a<\/div>\n<div>\u767e\u5ea6\u4e91\u76d8\uff08<a href=\"http:\/\/pan.baidu.com\/s\/1o6uO2jK\">http:\/\/pan.baidu.com\/s\/1o6uO2jK<\/a>\uff09<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u76f4\u63a5\u8c03\u7528Google Chart API\u63a5\u53e3 \u8c03\u7528\u6f14\u793a\uff1a &lt;form method=&#8221;pos &hellip; <a href=\"https:\/\/www.yclimw.com\/?p=954\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">PHP\u751f\u6210QR\u4e8c\u7ef4\u7801\u7684\u51e0\u79cd\u65b9\u6cd5<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[36,32,37,38],"class_list":["post-954","post","type-post","status-publish","format-standard","hentry","category-17","tag-google-chart","tag-php","tag-qrcode","tag-38"],"_links":{"self":[{"href":"https:\/\/www.yclimw.com\/index.php?rest_route=\/wp\/v2\/posts\/954","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yclimw.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yclimw.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yclimw.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yclimw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=954"}],"version-history":[{"count":7,"href":"https:\/\/www.yclimw.com\/index.php?rest_route=\/wp\/v2\/posts\/954\/revisions"}],"predecessor-version":[{"id":3073,"href":"https:\/\/www.yclimw.com\/index.php?rest_route=\/wp\/v2\/posts\/954\/revisions\/3073"}],"wp:attachment":[{"href":"https:\/\/www.yclimw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=954"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yclimw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=954"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yclimw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=954"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}