{"id":73,"date":"2023-01-10T15:08:57","date_gmt":"2023-01-10T07:08:57","guid":{"rendered":"https:\/\/9256.muqesjie.top\/?p=73"},"modified":"2023-01-10T15:08:57","modified_gmt":"2023-01-10T07:08:57","slug":"%e6%90%ad%e5%bb%ba%e9%9a%8f%e6%9c%ba%e5%9b%be%e7%89%87api","status":"publish","type":"post","link":"https:\/\/www.assin.top\/index.php\/2023\/01\/10\/%e6%90%ad%e5%bb%ba%e9%9a%8f%e6%9c%ba%e5%9b%be%e7%89%87api\/","title":{"rendered":"\u642d\u5efa\u968f\u673a\u56fe\u7247API"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><em>\u524d\u8a00\uff1a\u76ee\u524d\u642d\u5efa\u65b9\u6cd5\u6709\u4e24\u79cd\uff0c\u4e00\u4e2a\u662f\u5b58\u5728\u4e8e\u670d\u52a1\u5668\u6216\u8005\u865a\u62df\u673a\u7a7a\u95f4\u8c03\u7528\u7684\uff0c\u4e00\u4e2a\u662f\u4f7f\u7528\u5176\u4ed6\u56fe\u7247\u6258\u7ba1\u5e73\u53f0\u6216\u8005\u4f7f\u7528\u4ed6\u4eba\u7684url\u5b58\u5728\u4e8e\u6587\u672c\u4e2d\u518d\u8c03\u7528\u3002\uff08\u4f5c\u4e3aapi\u8c03\u7528\u7684\u5957\u4e86CDN\u540e\u53ea\u53ef\u6d4f\u89c8\u5668\u8bbf\u95ee\uff09<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>1.\u672c\u5730\u968f\u673a\u56fe\u7247<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u9996\u5148\u521b\u5efa\u4e00\u4e2a\u6587\u4ef6\u5939 photos \u548c\u4e00\u4e2a\u540d\u4e3a api.php \u7684\u6587\u4ef6 \u7136\u540e\u5728photos\u7684\u6587\u4ef6\u5939\u5185\u653e\u56fe\u7247\uff0c\u5728api.php\u5185\u7f16\u5199\u5982\u4e0b\u4ee3\u7801<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n$img_array = glob(\"photos\/*.{gif,jpg,png}\",GLOB_BRACE);\/\/photos\u662f\u81ea\u5df1\u8bbe\u7f6e\u6587\u4ef6\u5939\u53ef\u4ee5\u81ea\u884c\u66f4\u6539\n$img_count = count($img_array);\nif ($img_count > 0) {\n  $img = rand(0, $img_count - 1);\n  $dz = $img_array&#91;$img];\n  header(\"Location:\".$dz);\n}\n?>\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u4fdd\u5b58\u5373\u53ef\uff0c\u901a\u8fc7api\u968f\u673a\u8c03\u7528img\u6587\u4ef6\u5939\u4e2d\u7684\u56fe\u7247,\u6700\u540e\u8bbf\u95ee\u5730\u5740:http:\/\/<a rel=\"noreferrer noopener\" href=\"https:\/\/cloud.tencent.com\/act\/pro\/domain-sales?from=10680\" target=\"_blank\" rel=\"nofollow\" >\u57df\u540d<\/a>\/api.php\u5c31\u53ef\u4ee5\u5566\uff0c\u5957\u4e2a<a rel=\"noreferrer noopener\" href=\"https:\/\/cloud.tencent.com\/product\/cdn?from=10680\" target=\"_blank\" rel=\"nofollow\" >CDN<\/a>\u52a0\u901f\u540e\uff0c\u901f\u5ea6\u4e5f\u591f\u5feb\uff0c\u4f46\u662f\u4f1a\u6d88\u8017\u670d\u52a1\u5668\u6216\u8005\u865a\u62df\u673a\u7684\u5185\u5b58\uff0c\u6240\u4ee5\u5982\u679c\u662f\u7528\u672c\u5730\u5c31\u505a\u597d\u538b\u7f29\u56fe\u7247\u964d\u4f4e\u56fe\u7247\u5927\u5c0f\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>2.\u5916\u90e8URL\u94fe\u63a5<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u9996\u5148\u521b\u5efa photos.txt \u548c api.php \u6587\u4ef6 \u7136\u540e\u5728photos.txt\u6587\u6863\u5185\u653e\u56fe\u7247\u5916\u94fe\u5730\u5740 (\u4e00\u884c\u4e00\u4e2a) \uff0c\u5728api.php\u52a0\u5165\u4e0b\u5217\u4ee3\u7801<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\/\/ \u6b64php\u548c\u4fdd\u5b58\u94fe\u63a5\u7684txt\u6587\u4ef6\u653e\u5728\u540c\u4e00\u76ee\u5f55\u4e0b\n$filename = \"photos.txt\";  \/*\u4fdd\u5b58\u94fe\u63a5\u7684txt\u6587\u4ef6\u540d*\/\nif(!file_exists($filename)){\n    die('\u6587\u4ef6\u4e0d\u5b58\u5728');\n}\n\/\/ \u4ece\u6587\u672c\u83b7\u53d6\u94fe\u63a5\n$pics = &#91;];\n$fs = fopen($filename, \"r\");\nwhile(!feof($fs)){\n    $line=trim(fgets($fs));\n    if($line!=''){\n        array_push($pics, $line);\n    }\n}\n\/\/ \u4ece\u6570\u7ec4\u968f\u673a\u83b7\u53d6\u94fe\u63a5\n$pic = $pics&#91;array_rand($pics)];\n\/\/ \u8fd4\u56de\u6307\u5b9a\u683c\u5f0f\n$type=$_GET&#91;'type'];\nswitch($type){\n\/\/ JSON\u8fd4\u56de\ncase 'json':\n    header('Content-type:text\/json');\n    die(json_encode(&#91;'pic'=>$pic]));\ndefault:\n    die(header(\"Location: $pic\"));\n}\n?><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u4fdd\u5b58\u5373\u53ef\uff0c\u6700\u540e\u8bbf\u95ee\u5730\u5740:http:\/\/\u57df\u540d\/api.php\u5373\u53ef\uff01 \u8fd9\u91ccphotos. txt\u4e2d\u53ef\u4ee5\u586b\u5199\u6258\u7ba1\u5e73\u53f0\u7ed9\u7684URL<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u540c\u65f6\u56fe\u7247\u4e5f\u4e0d\u5efa\u8bae\u8fc7\u5927\uff0c\u4f1a\u589e\u52a0\u8bbf\u95ee\u65f6\u95f4\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u4f7f\u7528\u975e\u6d4f\u89c8\u5668\u8bbf\u95ee\u65f6\uff0c\u5982\u679c\u6258\u7ba1\u5e73\u53f0\u91c7\u53d6\u4e86\u9632\u76d7\u94fe\uff0c\u5c31\u65e0\u6cd5\u83b7\u53d6\u5230\u539f\u56fe\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4ee5\u4e0a\u5c31\u662f\u6240\u6709\u7684\u5185\u5bb9\u4e86<\/p>\n\n\n\n<figure class=\"wp-block-pullquote\"><blockquote><p><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">\u56fe\u7247\u5206\u4eab<\/mark><\/strong><\/p><\/blockquote><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/i.328888.xyz\/2023\/01\/07\/k8nHF.jpeg\" alt=\"\"\/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00\uff1a\u76ee\u524d\u642d\u5efa\u65b9\u6cd5\u6709\u4e24\u79cd\uff0c\u4e00\u4e2a\u662f\u5b58\u5728\u4e8e\u670d\u52a1\u5668\u6216\u8005\u865a\u62df\u673a\u7a7a\u95f4\u8c03\u7528\u7684\uff0c\u4e00\u4e2a\u662f\u4f7f\u7528\u5176\u4ed6\u56fe\u7247\u6258\u7ba1\u5e73\u53f0\u6216\u8005\u4f7f\u7528\u4ed6\u4eba\u7684url\u5b58\u5728\u4e8e\u6587\u672c\u4e2d\u518d\u8c03\u7528 &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[2],"tags":[],"class_list":["post-73","post","type-post","status-publish","format-standard","hentry","category-2"],"_links":{"self":[{"href":"https:\/\/www.assin.top\/index.php\/wp-json\/wp\/v2\/posts\/73","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.assin.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.assin.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.assin.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.assin.top\/index.php\/wp-json\/wp\/v2\/comments?post=73"}],"version-history":[{"count":0,"href":"https:\/\/www.assin.top\/index.php\/wp-json\/wp\/v2\/posts\/73\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.assin.top\/index.php\/wp-json\/wp\/v2\/media?parent=73"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.assin.top\/index.php\/wp-json\/wp\/v2\/categories?post=73"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.assin.top\/index.php\/wp-json\/wp\/v2\/tags?post=73"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}