{"id":1198,"date":"2010-01-26T23:29:18","date_gmt":"2010-01-26T15:29:18","guid":{"rendered":"http:\/\/nan.im\/blog\/?p=1198"},"modified":"2010-01-26T23:29:18","modified_gmt":"2010-01-26T15:29:18","slug":"%e5%a6%82%e4%bd%95%e7%94%a8-php-%e5%9c%a8%e7%bd%91%e7%ab%99%e4%b8%8a%e6%98%be%e7%a4%ba%e4%bd%a0%e6%9c%80%e6%96%b0%e7%9a%84%e5%be%ae%e5%8d%9a","status":"publish","type":"post","link":"https:\/\/nan.im\/blog\/1198","title":{"rendered":"\u5982\u4f55\u4f7f\u7528 PHP \u5728\u81ea\u5df1\u7f51\u7ad9\u4e0a\u663e\u793a\u6700\u65b0\u7684\u5fae\u535a"},"content":{"rendered":"<p>\u6700\u8fd1\u53d1\u73b0 twitter \u4e0a\u670b\u53cb\u8d8a\u6765\u8d8a\u51b7\u6e05\uff0c\u5927\u5bb6\u4e5f\u90fd\u5f00\u59cb\u65e0\u5948\u7684\u4f7f\u7528 <a href=\"http:\/\/t.sina.com.cn\/\">\u65b0\u6d6a\u5fae\u535a<\/a> \u4e86\uff0c\u4f46\u65b0\u6d6a\u4e00\u76f4\u6ca1\u6709\u5f00\u53d1\u6216\u5f00\u653e API \u662f\u5927\u5bb6\u6bd4\u8f83\u90c1\u95f7\u7684\u3002\u8fd9\u91cc\u63d0\u4f9b\u4e00\u4e2a\u6211\u5199\u7684\u5c0f PHP \u51fd\u6570\u53ef\u4ee5\u5e2e\u5927\u5bb6\u5728\u81ea\u5df1\u7684\u7ad9\u70b9\u4e0a\u663e\u793a\u8f93\u51fa\u6700\u8fd1\u66f4\u65b0\u7684\u5fae\u535a\u5185\u5bb9\uff0c\u4f7f\u7528 PHP \u83b7\u53d6\u6700\u65b0\u5fae\u535a\u7684\u51fd\u6570\u4e3a any_get_weibo($sinaId, $listNs) \u53c2\u6570\u5206\u522b\u662f\u4f60\u7684\u65b0\u6d6a\u5fae\u535a\u6570\u5b57 ID \u548c\u9700\u8981\u663e\u793a\u7684\u5fae\u535a\u6761\u6570\uff0c\u7531\u4e8e\u65b0\u6d6a\u5c0f\u7ec4\u4ef6\u7684\u9650\u5236\u6761\u6570\u4e0d\u80fd\u8d85\u8fc7 15 \u6761\u2026\u2026<!--more--><\/p>\n<p>\u5177\u4f53\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre lang=\"php\" line=\"1\">\nfunction any_get_weibo($sinaId, $listNs){\n\t$output  = '<ul>';\n\t$gethtm  = file_get_contents('http:\/\/v.t.sina.com.cn\/widget\/widget_blog.php?uid='. $sinaId .'');\n\t\t\/\/ \u8fd9\u91cc\u4ece\u4e00\u4e2a\u65b0\u6d6a\u5c0f\u7ec4\u4ef6\u91cc\u8c03\u7528\u6570\u636e\u6765\u6e90\u53ef\u4ee5\u51cf\u5c11\u4e00\u5b9a\u7684\u6570\u636e\u6d41\u4e5f\u53ef\u4ee5\u907f\u514d\u8df3\u5230\u767b\u9646\u9875\uff1b\n\t$tempOp  = explode('<p class=\"wgtCell_txt\">', $gethtm);\n\tfor($n = 1; $n <= $listNs; $n++){\n\t\t$tempTs  = explode('<\/p>', $tempOp[$n]);\n\t\t$output .= '<li>'.$tempTs[0].'<\/li>';\n\t}\n\t$output .= '<\/ul><a href=\"http:\/\/t.sina.com.cn\/'.$sinaId.'\/profile\">more...<\/a>';\n\treturn $output;\n}\n<\/pre>\n<p>\u7b80\u5355\u8bf4\u660e\uff1a\u6709\u4e86\u4e0a\u9762\u7684\u51fd\u6570\u5c31\u53ef\u4ee5\u4f7f\u7528 any_get_weibo($sinaId, $listNs) \u51fd\u6570\u6765\u76f4\u63a5\u83b7\u53d6\u4f60\u7684\u6700\u65b0\u5fae\u535a\u5185\u5bb9\u4e86\uff0c\u5176\u4e2d $sinaId \u662f\u4f60\u7684\u65b0\u6d6a\u5fae\u535a ID \u8fd9\u91cc\u7684 ID \u4e0d\u662f\u4e2a\u6027\u5316\u57df\u540d\u91cc\u9762\u7684 URL \u800c\u662f\u8bf8\u5982 1503269170 \u7c7b\u4f3c\u7684\u6570\u5b57 ID \u5426\u5219\u5c06\u53ef\u80fd\u65e0\u6cd5\u83b7\u53d6\u6570\u636e\uff0c\u83b7\u53d6\u8fd9\u4e2a\u6570\u5b57 ID \u53ef\u4ee5\u5728\u201c\u5173\u6ce8\u201d\u6216\u8005\u201c\u7c89\u4e1d\u201d\u7684\u9875\u9762\u5730\u5740 URL \u91cc\u9762\u5f88\u5bb9\u6613\u627e\u5230\uff1b\u540e\u9762\u7684 $listNs \u662f\u6253\u7b97\u83b7\u53d6\u591a\u5c11\u6761\u5fae\u535a\uff0c\u7531\u4e8e\u65b0\u6d6a\u8fd9\u4e2a widget \u6700\u591a\u53ea\u8f93\u51fa 15 \u6761\u5fae\u535a\uff0c\u6240\u4ee5\u8fd9\u4e2a\u53d8\u91cf\u4e0d\u80fd\u8d85\u8fc7 15 \u6761\uff0c\u5426\u5219\u5c06\u65e0\u6cd5\u83b7\u53d6\u3002<\/p>\n<p>\u62d3\u5c55\u4e00\u4e0b\uff1a\u53e6\u5916\u4e5f\u53ef\u4ee5\u4e3e\u4e00\u53cd\u4e09\uff0c\u5229\u7528 twitter \u7684 feed \u5730\u5740 http:\/\/search.twitter.com\/search.atom?q=from:anyLiv&#038;rpp=1 \u4e5f\u53ef\u4ee5\u53d6\u5230\u7528\u6237\u540d\u4e3a anyLiv \u7684\u6700\u65b0 tweet \u5185\u5bb9\u4e86\u3002\u8fd9\u91cc\u8fd9\u4e2a\u5c0f\u51fd\u6570\u53ea\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u5b9e\u73b0\uff0c\u539f\u7406\u662f\u628a\u65b0\u6d6a\u90a3\u4e2a\u5c0f\u7ec4\u4ef6\u8f93\u51fa\u7684\u6574\u4e2a\u9875\u9762\u62d4\u4e0b\u6765\u7136\u540e\u6309\u7167\u4e00\u4e9b\u89c4\u5f8b\u622a\u53d6\u51fa\u81ea\u5df1\u9700\u8981\u7684\u5185\u5bb9\uff0c\u81ea\u5df1\u4f7f\u7528\u7684\u65f6\u5019\u5f53\u7136\u53ef\u4ee5\u52a0\u4e00\u4e9b\u4fee\u9970\u6216\u8005\u622a\u53d6\u4e00\u4e0b\u8f93\u51fa\u5185\u5bb9\u7684\u957f\u5ea6\u53ca\u4f7f\u7528 &#038;showpic=0 \u53c2\u6570\u63a7\u5236\u4ee5\u54ea\u79cd\u65b9\u5f0f\u663e\u793a\u56fe\u7247\u7b49\u7b49\u5c31\u770b\u81ea\u5df1\u9700\u6c42\u4e86\uff0c\u987a\u4fbf\u62b1\u6028\u4e00\u4e0b\u65b0\u6d6a\u65e2\u7136\u5df2\u7ecf\u505a\u4e86\u5fae\u535a\u4e3a\u4ec0\u9ebd\u4e0d\u5f00\u653e API \u5462\u2026\u2026<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u53d1\u73b0 twitter \u4e0a\u670b\u53cb\u8d8a\u6765\u8d8a\u51b7\u6e05\uff0c\u5927\u5bb6\u4e5f\u90fd\u5f00\u59cb\u65e0\u5948\u7684\u4f7f\u7528 \u65b0\u6d6a\u5fae\u535a \u4e86\uff0c\u4f46\u65b0\u6d6a\u4e00\u76f4\u6ca1\u6709\u5f00\u53d1\u6216\u5f00\u653e A [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[20,24,120,69],"class_list":["post-1198","post","type-post","status-publish","format-standard","hentry","category-tech","tag-code","tag-develop","tag-php","tag-sina"],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":6}},"_links":{"self":[{"href":"https:\/\/nan.im\/blog\/wp-json\/wp\/v2\/posts\/1198","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nan.im\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nan.im\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nan.im\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nan.im\/blog\/wp-json\/wp\/v2\/comments?post=1198"}],"version-history":[{"count":0,"href":"https:\/\/nan.im\/blog\/wp-json\/wp\/v2\/posts\/1198\/revisions"}],"wp:attachment":[{"href":"https:\/\/nan.im\/blog\/wp-json\/wp\/v2\/media?parent=1198"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nan.im\/blog\/wp-json\/wp\/v2\/categories?post=1198"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nan.im\/blog\/wp-json\/wp\/v2\/tags?post=1198"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}