{"id":526,"date":"2015-04-02T12:23:23","date_gmt":"2015-04-02T04:23:23","guid":{"rendered":"http:\/\/www.zyuns.com\/?p=526"},"modified":"2015-10-22T15:27:52","modified_gmt":"2015-10-22T07:27:52","slug":"%e5%be%ae%e4%bf%a1%e5%88%86%e4%ba%ab%e5%88%b0%e6%9c%8b%e5%8f%8b%e5%9c%88%ef%bc%8c%e5%88%86%e4%ba%ab%e7%bb%99%e6%9c%8b%e5%8f%8bjs%e4%bb%a3%e7%a0%81","status":"publish","type":"post","link":"https:\/\/www.siediyer.cn\/?p=526","title":{"rendered":"\u5fae\u4fe1\u5206\u4eab\u5230\u670b\u53cb\u5708\uff0c\u5206\u4eab\u7ed9\u670b\u53cbJS\u4ee3\u7801"},"content":{"rendered":"<p>\u8bf4\u660e\uff1a2015\u5e74\uff0c\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u5347\u7ea7\u4e86\u5f00\u53d1\u6587\u6863\u3002<\/p>\n<p>\u5176\u5b9e\u5c31\u662f\u9650\u5236\u4e86\u6ca1\u6709\u52a0\u5165\u516c\u4f17\u5e73\u53f0\u7684\u4eba\u7684\u5206\u4eab\u6743\u9650\u3002<\/p>\n<p>\u5982\u679c\u4f60\u6ca1\u6709\u516c\u4f17\u5e73\u53f0\u7684\u8d26\u53f7\uff0c\u4f60\u4e5f\u53ef\u4ee5copy\u8fc7\u53bb\u4f7f\u7528\uff0c\u53ea\u662f\u5206\u4eab\u7684\u65f6\u5019\u6ca1\u6709\u4ecb\u7ecd\uff0c\u53ea\u6709\u6807\u9898\u548c\u56fe\u7247\u3002<\/p>\n<p>\u53f3\u4e0b\u89d2\u7070\u8272\u7684\u4ecb\u7ecd\u4f1a\u7528\u4e00\u4e2a\u5f53\u524d\u7684\u7f51\u5740\u4ee3\u66ff\u3002<\/p>\n<p>\u63d0\u793a\uff1a\u6700\u597d\u53bb\u6ce8\u518c\u4e2a\u8d26\u53f7<a title=\"\" href=\"https:\/\/mp.weixin.qq.com\/\" data-original-title=\"\">https:\/\/mp.weixin.qq.com<\/a><\/p>\n<p>\u6ce8\u518c\u7684\u5e94\u8be5\u662f\u975e\u4e2a\u4eba\u7684\u8ba2\u9605\u53f7\uff0c\u4e0d\u7136\u6ca1\u6709\u5206\u4eab\u7684\u529f\u80fd\u3002\u4e0d\u7528\u8c22~<\/p>\n<p>\u6548\u679c\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-663\" src=\"http:\/\/www.siediyer.cn\/wp-content\/uploads\/2015\/10\/20150324215212_42504.jpg\" width=\"720\" height=\"1280\" alt=\"\" title=\"1.pic.jpg\" srcset=\"https:\/\/qiniu.shijitianchen.com\/2015\/10\/20150324215212_42504.jpg 720w, https:\/\/qiniu.shijitianchen.com\/2015\/10\/20150324215212_42504-169x300.jpg 169w, https:\/\/qiniu.shijitianchen.com\/2015\/10\/20150324215212_42504-576x1024.jpg 576w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/p>\n<p>\u9996\u5148\u8981\u505a\u4e00\u4e2aphp\u7684\u51fd\u6570<\/p>\n<p>\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre class=\"lang:default decode:true \">function jssdk(){\r\n        $appid = '\u8fd9\u91cc\u66ff\u6362\u6210\u4f60\u7684appid';\r\n        $secret = '\u8fd9\u91cc\u66ff\u6362\u6210\u4f60\u7684key';\r\n        $_title = '\u5fae\u4fe1';\r\n        $code = $_GET['code'];\/\/\u83b7\u53d6code\r\n        $_SESSION['code'] = $code;\/\/\u8bbe\u7f6ecode\u7f13\u5b58\u7ed9\u5fae\u4fe1\u4ed8\u8d26\u4f7f\u7528\r\n        $auth = file_get_contents(\"https:\/\/api.weixin.qq.com\/sns\/oauth2\/access_token?appid=\".$appid.\"&amp;secret=\".$secret.\"&amp;code=\".$code.\"&amp;grant_type=authorization_code\");\/\/\u901a\u8fc7code\u6362\u53d6\u7f51\u9875\u6388\u6743access_token\r\n        $jsonauth = json_decode($auth); \/\/\u5bf9JSON\u683c\u5f0f\u7684\u5b57\u7b26\u4e32\u8fdb\u884c\u7f16\u7801\r\n        $arrayauth = get_object_vars($jsonauth);\/\/\u8f6c\u6362\u6210\u6570\u7ec4\r\n        $openid = $arrayauth['openid'];\/\/\u8f93\u51faopenid\r\n        $access_token = $arrayauth['access_token'];\r\n        $_SESSION['openid'] = $openid;\r\n         \r\n        $accesstoken = file_get_contents(\"https:\/\/api.weixin.qq.com\/cgi-bin\/token?grant_type=client_credential&amp;appid=\".$appid.\"&amp;secret=\".$secret.\"\");\/\/\u83b7\u53d6access_token\r\n        $token = json_decode($accesstoken); \/\/\u5bf9JSON\u683c\u5f0f\u7684\u5b57\u7b26\u4e32\u8fdb\u884c\u7f16\u7801\r\n        $t = get_object_vars($token);\/\/\u8f6c\u6362\u6210\u6570\u7ec4\r\n        $access_token = $t['access_token'];\/\/\u8f93\u51faaccess_token\r\n         \r\n        $jsapi = file_get_contents(\"https:\/\/api.weixin.qq.com\/cgi-bin\/ticket\/getticket?access_token=\".$access_token.\"&amp;type=jsapi\");\r\n        $jsapi = json_decode($jsapi);\r\n        $j = get_object_vars($jsapi);\r\n        $jsapi = $j['ticket'];\/\/get JSAPI\r\n         \r\n        $time = 14999923234;\r\n        $noncestr= $time;\r\n        $jsapi_ticket= $jsapi;\r\n        $timestamp=$time;\r\n        $url='http:\/\/'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];\r\n        $and = \"jsapi_ticket=\".$jsapi_ticket.\"&amp;noncestr=\".$noncestr.\"&amp;timestamp=\".$timestamp.\"&amp;url=\".$url.\"\";\r\n        $signature = sha1($and);\r\n        return $signature;\r\n    }<\/pre>\n<p>&nbsp;<\/p>\n<p>\u6700\u540e\u7684\u4e00\u53e5\u4ee3\u7801\uff0c\u5c31\u662f\u8bf4\uff0c\u5982\u679c\u4f60\u5728\u8f93\u51fa\u9875\u9762\u4f7f\u7528&lt;?=jssdk();?&gt;,\u90a3\u4e48\u5c31\u4f1a\u8f93\u51fa$signature\u7684\u5185\u5bb9\u3002\u5176\u4e2d\u4e0a\u9762\u7684$time\u662f\u6211\u624b\u52a8\u6307\u5b9a\u7684\uff0c\u8fd9\u4e2a\u4e00\u5b9a\u8981\u8ddf\u8f93\u51fa\u9875\u9762\u7684js\u4ee3\u7801\u7684\u503c\u4e00\u6837\u3002<\/p>\n<p>\u8f93\u51fa\u9875\u9762\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre class=\"lang:default decode:true \">&lt;script type=\"text\/javascript\" src=\"http:\/\/res.wx.qq.com\/open\/js\/jweixin-1.0.0.js\"&gt;&lt;\/script&gt;\r\n&lt;script language=\"javascript\" type=\"text\/javascript\"&gt;\r\nwx.config({\r\n    debug: false,\/\/\u8fd9\u91cc\u662f\u5f00\u542f\u6d4b\u8bd5\uff0c\u5982\u679c\u8bbe\u7f6e\u4e3atrue\uff0c\u5219\u6253\u5f00\u6bcf\u4e2a\u6b65\u9aa4\uff0c\u90fd\u4f1a\u6709\u63d0\u793a\uff0c\u662f\u5426\u6210\u529f\u6216\u8005\u5931\u8d25\r\n    appId: '\u8fd9\u91cc\u6362\u6210\u4f60\u7684appid',\r\n    timestamp: '14999923234',\/\/\u8fd9\u4e2a\u4e00\u5b9a\u8981\u4e0e\u4e0a\u9762\u7684php\u4ee3\u7801\u91cc\u7684\u4e00\u6837\u3002\r\n    nonceStr: '14999923234',\/\/\u8fd9\u4e2a\u4e00\u5b9a\u8981\u4e0e\u4e0a\u9762\u7684php\u4ee3\u7801\u91cc\u7684\u4e00\u6837\u3002\r\n    signature: '&lt;?=jssdk();?&gt;',\r\n    jsApiList: [\r\n      \/\/ \u6240\u6709\u8981\u8c03\u7528\u7684 API \u90fd\u8981\u52a0\u5230\u8fd9\u4e2a\u5217\u8868\u4e2d\r\n        'onMenuShareTimeline',\r\n        'onMenuShareAppMessage',\r\n        'onMenuShareQQ',\r\n        'onMenuShareWeibo'\r\n    ]\r\n});\r\nwx.ready(function () {\r\n    wx.onMenuShareTimeline({\r\n        title: \"&lt;?=$act['act_name']?&gt;\", \/\/ \u5206\u4eab\u6807\u9898\r\n        link: \"http:\/\/www.brandhd.com\/v\/events\/view\/&lt;?=$act['act_id']?&gt;\", \/\/ \u5206\u4eab\u94fe\u63a5\r\n        imgUrl: \"http:\/\/www.brandhd.com&lt;?=$act['act_poster_small']?&gt;\", \/\/ \u5206\u4eab\u56fe\u6807\r\n        success: function () { \r\n            \/\/ \u7528\u6237\u786e\u8ba4\u5206\u4eab\u540e\u6267\u884c\u7684\u56de\u8c03\u51fd\u6570\r\n        },\r\n        cancel: function () { \r\n            \/\/ \u7528\u6237\u53d6\u6d88\u5206\u4eab\u540e\u6267\u884c\u7684\u56de\u8c03\u51fd\u6570\r\n        }\r\n    });\r\n    wx.onMenuShareAppMessage({\r\n        title: \"&lt;?=$act['act_name']?&gt;\", \/\/ \u5206\u4eab\u6807\u9898\r\n        desc: \"&lt;?=substr($act['act_stime'],0,10)?&gt;&lt;?=$act['act_place']?&gt;\", \/\/ \u5206\u4eab\u63cf\u8ff0\r\n        link: \"http:\/\/www.brandhd.com\/v\/events\/view\/&lt;?=$act['act_id']?&gt;\", \/\/ \u5206\u4eab\u94fe\u63a5\r\n        imgUrl: \"http:\/\/www.brandhd.com&lt;?=$act['act_poster_small']?&gt;\", \/\/ \u5206\u4eab\u56fe\u6807\r\n        type: '', \/\/ \u5206\u4eab\u7c7b\u578b,music\u3001video\u6216link\uff0c\u4e0d\u586b\u9ed8\u8ba4\u4e3alink\r\n        dataUrl: '', \/\/ \u5982\u679ctype\u662fmusic\u6216video\uff0c\u5219\u8981\u63d0\u4f9b\u6570\u636e\u94fe\u63a5\uff0c\u9ed8\u8ba4\u4e3a\u7a7a\r\n        success: function () { \r\n            \/\/ \u7528\u6237\u786e\u8ba4\u5206\u4eab\u540e\u6267\u884c\u7684\u56de\u8c03\u51fd\u6570\r\n        },\r\n        cancel: function () { \r\n            \/\/ \u7528\u6237\u53d6\u6d88\u5206\u4eab\u540e\u6267\u884c\u7684\u56de\u8c03\u51fd\u6570\r\n        }\r\n    });\r\n    wx.onMenuShareQQ({\r\n        title: \"&lt;?=$act['act_name']?&gt;\", \/\/ \u5206\u4eab\u6807\u9898\r\n        desc: \"&lt;?=substr($act['act_stime'],0,10)?&gt;n&lt;?=$act['act_place']?&gt;\", \/\/ \u5206\u4eab\u63cf\u8ff0\r\n        link: \"http:\/\/www.brandhd.com\/v\/events\/view\/&lt;?=$act['act_id']?&gt;\", \/\/ \u5206\u4eab\u94fe\u63a5\r\n        imgUrl: \"http:\/\/www.brandhd.com&lt;?=$act['act_poster_small']?&gt;\", \/\/ \u5206\u4eab\u56fe\u6807\r\n        success: function () { \r\n           \/\/ \u7528\u6237\u786e\u8ba4\u5206\u4eab\u540e\u6267\u884c\u7684\u56de\u8c03\u51fd\u6570\r\n        },\r\n        cancel: function () { \r\n           \/\/ \u7528\u6237\u53d6\u6d88\u5206\u4eab\u540e\u6267\u884c\u7684\u56de\u8c03\u51fd\u6570\r\n        }\r\n    });\r\n    wx.onMenuShareWeibo({\r\n        title: \"&lt;?=$act['act_name']?&gt;\", \/\/ \u5206\u4eab\u6807\u9898\r\n        desc: \"&lt;?=substr($act['act_stime'],0,10)?&gt;n&lt;?=$act['act_place']?&gt;\", \/\/ \u5206\u4eab\u63cf\u8ff0\r\n        link: \"http:\/\/www.brandhd.com\/v\/events\/view\/&lt;?=$act['act_id']?&gt;\", \/\/ \u5206\u4eab\u94fe\u63a5\r\n        imgUrl: \"http:\/\/www.brandhd.com&lt;?=$act['act_poster_small']?&gt;\", \/\/ \u5206\u4eab\u56fe\u6807\r\n        success: function () { \r\n           \/\/ \u7528\u6237\u786e\u8ba4\u5206\u4eab\u540e\u6267\u884c\u7684\u56de\u8c03\u51fd\u6570\r\n        },\r\n        cancel: function () { \r\n            \/\/ \u7528\u6237\u53d6\u6d88\u5206\u4eab\u540e\u6267\u884c\u7684\u56de\u8c03\u51fd\u6570\r\n        }\r\n    });\r\n});\r\n&lt;\/script&gt;<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8bf4\u660e\uff1a2015\u5e74\uff0c\u5fae\u4fe1\u516c\u4f17\u5e73\u53f0\u5347\u7ea7\u4e86\u5f00\u53d1\u6587\u6863\u3002 \u5176\u5b9e\u5c31\u662f\u9650\u5236\u4e86\u6ca1\u6709\u52a0\u5165\u516c\u4f17\u5e73\u53f0\u7684\u4eba\u7684\u5206\u4eab\u6743\u9650\u3002 \u5982\u679c\u4f60\u6ca1\u6709\u516c\u4f17 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":663,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[10,11],"class_list":["post-526","post","type-post","status-publish","format-standard","hentry","category-php","tag-10","tag-js"],"_links":{"self":[{"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=\/wp\/v2\/posts\/526","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=526"}],"version-history":[{"count":2,"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=\/wp\/v2\/posts\/526\/revisions"}],"predecessor-version":[{"id":664,"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=\/wp\/v2\/posts\/526\/revisions\/664"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=\/wp\/v2\/media\/663"}],"wp:attachment":[{"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=526"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=526"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.siediyer.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=526"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}