灏忕▼搴忎簯鍑芥暟璋冪敤webservice鎺ュ彛
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了灏忕▼搴忎簯鍑芥暟璋冪敤webservice鎺ュ彛相关的知识,希望对你有一定的参考价值。
鏍囩锛?a href='http://www.mamicode.com/so/1/%e7%a8%8b%e5%ba%8f' title='绋嬪簭'>绋嬪簭 eve 杩愯鐜 ring token -- fun ror console
https://www.jianshu.com/p/2692e56251ac
灏忕▼搴忔渶杩戞柊鍑烘潵浜嗕簯寮€鍙戣兘鍔涳紝涓昏渚濊禆浜唍ode.js锛堣繍琛屽湪鏈嶅姟鍣ㄤ笂鐨刯s锛夛紝鍙互璁╂垜浠湪娌℃湁鏈嶅姟鍣ㄧ殑鎯呭喌涓嬶紝浣跨敤浜戝紑鍙戠殑鏁版嵁搴擄紝缂栧啓浜戝嚱鏁帮紙鐩稿綋浜庢帴鍙o級鏉ュ畬鎴愪竴鏁村灏忕▼搴忕殑寮€鍙戯紝鍚庣浠€涔堢殑锛屾垜浠笉闇€瑕侊紒
浠ヤ笂绮楃暐浠嬬粛涓€涓嬩簯寮€鍙戠殑鑳藉姏锛屼笅闈㈣█褰掓浼狅紝鍏充簬璋冪敤webservice鎺ュ彛锛坵sdl)锛屽皬绋嬪簭鍦ㄤ笉浣跨敤浜戝嚱鏁扮洿鎺ョ敤鏅€氬紑鍙戞ā寮忕殑js閫氳繃request涔熻兘璇锋眰锛屼絾杩欐牱瀛樺湪鐨勭己鐐规槸锛?/p>
- 1.鍩熷悕蹇呴』璁よ瘉锛堝惁鍒欐墜鏈哄彧鑳藉湪璋冭瘯妯″紡涓嬫墠鑳借闂帴鍙o紝杩欐牱灏忕▼搴忔病娉曞彂甯冿級
- 2.涓嶈兘璇锋眰http寮€澶寸殑
鑰屾垜浠湪浜戝嚱鏁颁腑璋冪敤鎺ュ彛锛屽氨鑳借烦杩囧井淇″杩欎袱鐐圭殑楠岃瘉锛屽彧瑕佹湁鑷繁鏈嶅姟鍣ㄧ殑IP锛屽氨鑳藉畬鎴愬紑鍙戝彂甯冨皬绋嬪簭
涓嬮潰璁叉搷浣滐細
- 1 鏂板缓浜戝嚱鏁帮細浠g爜濡備笅
const cloud = require(鈥榳x-server-sdk鈥?span class="token punctuation">)
const soap = require(鈥榮oap鈥?span class="token punctuation">)
cloud.init()
const db = cloud.database()
// 浜戝嚱鏁板叆鍙e嚱鏁?exports.main = async(event, context) => {
const urls = 鈥樻帴鍙e湴鍧€鈥?span class="token punctuation">;
const args = {
鈥榰rl鈥?span class="token punctuation">: event.url,
鈥榰sercode鈥?span class="token punctuation">: event.usercode,
鈥榩wd鈥?span class="token punctuation">: event.pwd,
鈥榦s鈥?span class="token punctuation">: 鈥榳eixin鈥? };
return new Promise((resolve, reject) => {
soap.createClient(urls, function(err, client) {
if (err) {
console.log(err);
}
//杩斿洖涓€涓鎴风锛屽苟涓斾紶鍙傝皟鐢↗ava鐨勬帴鍙o紝鎺ユ敹杩斿洖鐨勬暟鎹? client.convertURL(args, function(error, result) {
//鎵撳嵃鎺ユ敹鍒扮殑鏁版嵁
resolve(result)
});
});
})
}
杩欓噷闇€瑕佹敞鎰忕殑鏄細
浜戝嚱鏁颁腑浣跨敤 wx-server-sdk 闇€鍦ㄥ搴斾簯鍑芥暟鐩綍涓嬪畨瑁?wx-server-sdk 渚濊禆锛屽湪鍒涘缓浜戝嚱鏁版椂浼氬湪浜戝嚱鏁扮洰褰曚笅榛樿鏂板缓涓€涓?package.json 骞舵彁绀虹敤鎴锋槸鍚︾珛鍗虫湰鍦板畨瑁呬緷璧栥€傝娉ㄦ剰浜戝嚱鏁扮殑杩愯鐜鏄?Node.js锛屽洜姝ゅ湪鏈湴瀹夎渚濊禆鏃跺姟蹇呬繚璇佸凡瀹夎 Node.js锛屽悓鏃?node 鍜?npm 閮藉湪鐜鍙橀噺涓€傚涓嶆湰鍦板畨瑁呬緷璧栵紝鍙互鐢ㄥ懡浠よ鍦?code>璇ョ洰褰曚笅杩愯(浜戝嚱鏁扮洰褰曚笅锛夛細
npm install --save wx-server-sdk@latest
鍚岀悊锛宻oap渚濊禆
npm install --save soap@latest
- 2 鍦╦s涓皟鐢ㄤ簯鍑芥暟
wx.cloud.callFunction({
name: 鈥榗onvertURL鈥?span class="token punctuation">,
data: {//浼犵粰浜戝嚱鏁扮殑鍙傛暟
url: that.data.url,
usercode: 鈥榶aya鈥?span class="token punctuation">,
pwd: 鈥?4yaya鈥? },
success: res => {
var playurl = res.result.return;
playurl = JSON.parse(playurl);
console.log(playurl.data.url);
that.setData({
playurl: playurl.data.url
})
wx.showToast({
title: 鈥樺湴鍧€璇诲彇鎴愬姛,璇疯€愬績绛夊緟鈥?span class="token punctuation">,
icon: 鈥榥one鈥?span class="token punctuation">,
duration: 3000
})
},
fail: res => {
wx.showToast({
title: 鈥樺湴鍧€閿欒鈥?span class="token punctuation">,
icon: 鈥榥one鈥?span class="token punctuation">,
duration: 2000
})
}
})
ok,澶у姛鍛婃垚銆傛湁鐢ㄧ殑璇濈偣涓禐鍚?/p>
以上是关于灏忕▼搴忎簯鍑芥暟璋冪敤webservice鎺ュ彛的主要内容,如果未能解决你的问题,请参考以下文章