{"id":29962,"date":"2024-11-25T16:55:03","date_gmt":"2024-11-25T08:55:03","guid":{"rendered":"https:\/\/fwq.ai\/blog\/29962\/"},"modified":"2024-11-25T16:55:03","modified_gmt":"2024-11-25T08:55:03","slug":"%e5%a6%82%e4%bd%95%e6%8a%8adedecms%e6%95%b0%e6%8d%ae%e7%94%9f%e6%88%90json","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/29962\/","title":{"rendered":"\u5982\u4f55\u628adedecms\u6570\u636e\u751f\u6210json"},"content":{"rendered":"<p style=\"text-align: center\"><strong><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/000\/020\/5de474a0e2538764.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u628adedecms\u6570\u636e\u751f\u6210json\u63d2\u56fe\" alt=\"\u5982\u4f55\u628adedecms\u6570\u636e\u751f\u6210json\u63d2\u56fe\" \/><\/strong><\/p>\n<p><strong>\u5982\u4f55\u628a\u6570\u636e\u751f\u6210json\uff1f<\/strong><\/p>\n<p>\u540d\u79f0\uff1ajson\u6570\u636e\u8c03\u7528<\/p>\n<p>\u529f\u80fd\uff1a\u8c03\u7528\u67d0\u4e2a\u8fdc\u7a0b\u8fde\u63a5\u7684json\u63a5\u53e3\uff0c\u65b9\u4fbf\u540c\u8fdc\u7a0b\u7ad9\u70b9\u4e4b\u95f4\u8fdb\u884c\u901a\u4fe1\u6765\u8c03\u53d6\u5185\u5bb9<\/p>\n<p>\u63a8\u8350\u5b66\u4e60\uff1a<\/p>\n<p>\u8bed\u6cd5\uff1a<\/p>\n<pre>{dede:json&nbsp;url='http:\/\/news\/json.php'&nbsp;cache=300}\n[field:id\/]-[field:title\/]&lt;br&gt;\n{\/dede:json}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4f60\u53ef\u4ee5\u628a\u8fd9\u6bb5\u4ee3\u7801\u6254\u5230\u4f60\u60f3\u8981\u8c03\u7528\u7684\u5730\u65b9\u5c31ok\u4e86\uff01<\/p>\n<p>cache=300 \u7f13\u5b58\u65f6\u95f4\uff0c0\u4e3a\u4e0d\u7f13\u5b58<\/p>\n<p>\u6211\u4eec\u9996\u5148\u7f16\u5199\u4e00\u4e2a\u7b80\u5355\u7684\u670d\u52a1\u5668\u7aefAPI\uff0c\u5c06\u5176\u5b58\u653e\u5728\u7cfb\u7edf\u6839\u76ee\u5f55\/api\u4e0b\uff08\u4e5f\u53ef\u4ee5\u76f4\u63a5\u5efa\u7acb\u4e2ajson.php\uff09\uff0c\u7531\u4e8e\u7cfb\u7edf\u662fGB2312\u7f16\u7801\uff0c\u6240\u4ee5\u670d\u52a1\u7aef\u7f16\u5199\u7684\u65f6\u5019\u6211\u4eec\u8fdb\u884c\u4e86\u4e00\u4e9b\u7f16\u7801\u8f6c\u6362\u7684\u5904\u7406\uff0c\u4fdd\u8bc1\u670d\u52a1\u7aef\u8bbf\u95ee\u7684\u7f16\u7801\u662fUTF-8\u5c31\u53ef\u4ee5\u3002<\/p>\n<p>\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre>&lt;?php $cfg_NotPrintHead = false;\nheader(\"Content-Type: text\/html; charset=utf-8\");\ninclude_once (dirname(__FILE__).\"\/..\/include\/common.inc.php\");\nerror_reporting(E_ALL || ~E_NOTICE);\nrequire_once(DEDEINC.&#039;\/json.class.php&#039;);\n$reval = array();\n$dsql-&gt;SetQuery(\"SELECT&nbsp;id,title&nbsp;FROM&nbsp;`dede_archives`&nbsp;ORDER&nbsp;BY&nbsp;id&nbsp;DESC&nbsp;LIMIT&nbsp;0,10\");\n$dsql-&amp;gt;Execute('me');\nwhile&nbsp;($row&nbsp;=&nbsp;$dsql-&amp;gt;GetArray('me'))&nbsp;{\n$row['title']&nbsp;=&nbsp;gb2utf8($row['title']);\n$reval[]&nbsp;=&nbsp;$row;\n}\n$json&nbsp;=&nbsp;new&nbsp;Services_JSON(SERVICES_JSON_SUPPRESS_ERRORS);\necho&nbsp;$json-&amp;gt;encode($reval);\n&nbsp;\n?&amp;gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u628a\u6570\u636e\u751f\u6210json\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u628a\u6570\u636e\u751f\u6210json\uff1f \u540d\u79f0\uff1ajson\u6570\u636e\u8c03\u7528 \u529f\u80fd\uff1a\u8c03\u7528\u67d0\u4e2a\u8fdc\u7a0b\u8fde\u63a5\u7684json\u63a5\u53e3\uff0c\u65b9\u4fbf\u540c\u8fdc\u7a0b\u7ad9\u70b9\u4e4b\u95f4\u8fdb\u884c\u901a\u4fe1\u6765\u8c03\u53d6\u5185\u5bb9 \u63a8\u8350\u5b66\u4e60\uff1a \u8bed\u6cd5\uff1a {dede:json&nbsp;url=&#8217;http:\/\/news\/json.php&#8217;&nbsp;cache=300} [field:id\/]-[field:title\/]&lt;br&gt; {\/dede:json} \u767b\u5f55\u540e\u590d\u5236 \u4f60\u53ef\u4ee5\u628a\u8fd9\u6bb5\u4ee3\u7801\u6254\u5230\u4f60\u60f3\u8981\u8c03\u7528\u7684\u5730\u65b9\u5c31ok\u4e86\uff01 cache=300 \u7f13\u5b58\u65f6\u95f4\uff0c0\u4e3a\u4e0d\u7f13\u5b58 \u6211\u4eec\u9996\u5148\u7f16\u5199\u4e00\u4e2a\u7b80\u5355\u7684\u670d\u52a1\u5668\u7aefAPI\uff0c\u5c06\u5176\u5b58\u653e\u5728\u7cfb\u7edf\u6839\u76ee\u5f55\/api\u4e0b\uff08\u4e5f\u53ef\u4ee5\u76f4\u63a5\u5efa\u7acb\u4e2ajson.php\uff09\uff0c\u7531\u4e8e\u7cfb\u7edf\u662fGB2312\u7f16\u7801\uff0c\u6240\u4ee5\u670d\u52a1\u7aef\u7f16\u5199\u7684\u65f6\u5019\u6211\u4eec\u8fdb\u884c\u4e86\u4e00\u4e9b\u7f16\u7801\u8f6c\u6362\u7684\u5904\u7406\uff0c\u4fdd\u8bc1\u670d\u52a1\u7aef\u8bbf\u95ee\u7684\u7f16\u7801\u662fUTF-8\u5c31\u53ef\u4ee5\u3002 \u4ee3\u7801\u5982\u4e0b\uff1a &lt;?php $cfg_NotPrintHead = false; header(&#8220;Content-Type: text\/html; charset=utf-8&#8243;); include_once (dirname(__FILE__).&#8221;\/..\/include\/common.inc.php&#8221;); error_reporting(E_ALL || ~E_NOTICE); require_once(DEDEINC.&#039;\/json.class.php&#039;); $reval = array(); $dsql-&gt;SetQuery(&#8220;SELECT&nbsp;id,title&nbsp;FROM&nbsp;`dede_archives`&nbsp;ORDER&nbsp;BY&nbsp;id&nbsp;DESC&nbsp;LIMIT&nbsp;0,10&#8221;); $dsql-&amp;gt;Execute(&#8216;me&#8217;); while&nbsp;($row&nbsp;=&nbsp;$dsql-&amp;gt;GetArray(&#8216;me&#8217;))&nbsp;{ $row[&#8216;title&#8217;]&nbsp;=&nbsp;gb2utf8($row[&#8216;title&#8217;]); $reval[]&nbsp;=&nbsp;$row; } $json&nbsp;=&nbsp;new&nbsp;Services_JSON(SERVICES_JSON_SUPPRESS_ERRORS); echo&nbsp;$json-&amp;gt;encode($reval); &nbsp; ?&amp;gt; \u767b\u5f55\u540e\u590d\u5236 \u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u628a\u6570\u636e\u751f\u6210json\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-29962","post","type-post","status-publish","format-standard","hentry","category-cms"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/29962","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=29962"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/29962\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=29962"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=29962"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=29962"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}