-1
我是一個鍋爐板程序員,所以對腳本的工作方式沒有太多技術上的深入。如何添加輸入字段到Yammer API查詢
我具有用於從Yammer的拉動用戶信息的哭訴API:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<span id="yammer-login"></span>
<script type="text/javascript" data-app-id="bdlZbJHCm1RY8pMUbuoBlQ" src="https://c64.assets-yammer.com/assets/platform_js_sdk.js"></script>
<script>
yam.getLoginStatus(
function (response) {
var result = 1625803434;
if (response.authResponse) {
console.log("logged in");
yam.platform.request({
url: "users/"+result+".json",
method: "GET",
data: { //use the data object literal to specify parameters, as documented in the REST API section of this developer site
"User_Id": result,
},
success: function (user) { //print message response information to the console
str = JSON.stringify(user, null, 4); // (Optional) beautiful indented output.
document.write(str);
},
error: function (user) {
alert("There was an error with the request.");
}
});
}
else {
alert("not logged in")
}
}
);
</script>
</body>
</html>
我不得不硬編碼Yammer的ID到它使用結果變量。
我試着添加一個輸入框,然後yam.getLoginStatus失敗: alert(「請求發生錯誤」);
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<form id="frm1" action="#" method="post">
Yammer ID: <input type="text" name="y_id"><br><br>
<input type="submit" onclick="yam_id()" value="Submit">
</form>
<span id="yammer-login"></span>
<script type="text/javascript" data-app-id="bdlZbJHCm1RY8pMUbuoBlQ" src="https://c64.assets-yammer.com/assets/platform_js_sdk.js"></script>
<script>
yam.getLoginStatus(
function (response) {
var result = 1625803434;
frm_i=document.getElementById("frm1");
result=frm_i.elements[0].value;
// alert (result);
if (response.authResponse) {
console.log("logged in");
yam.platform.request({
url: "users/"+result+".json",
method: "GET",
data: { //use the data object literal to specify parameters, as documented in the REST API section of this developer site
"User_Id": result,
},
success: function (user) { //print message response information to the console
str = JSON.stringify(user, null, 4); // (Optional) beautiful indented output.
document.write(str);
//console.dir(user);
},
error: function (user) {
alert("There was an error with the request.");
}
});
}
else {
alert("not logged in")
}
}
);
</script>
有誰知道如何簡單地爲這個腳本添加一個輸入框?
謝謝你的更新。 。 我可以得到一個輸入,這個問題正在通過輸入yam.getLoginStatus( ,然後再運行 在它從輸入框中接收到的任何輸入之前運行時刻 – hrhsii
你讀過https://開頭開發商.yammer.com/docs/js-sdk? 您錯過這段代碼: 'yam.connect.loginButton('#yammer-login',function(resp){ if(resp.authResponse){ document .getElementById('yammer-login')。innerHTML ='Welcome t Yammer!'; }' – loelsonk
嗨, 我可以登錄沒有問題,我只需要知道如何將我輸入的yammer id傳遞給yammer api腳本。 它全部運行並正常工作,如果我在結果變量中硬編碼yammer id。 – hrhsii