gpt4 book ai didi

javascript - Yammer REST API 用于创建主题状态并获取主题 ID

转载 作者:行者123 更新时间:2023-11-28 07:56:31 25 4
gpt4 key购买 nike

我想使用 php 和 javascript 创建 yammer 状态。这是我的示例代码-

    <script type="text/javascript" data-app-id="client-id" src="https://c64.assets-yammer.com/assets/platform_js_sdk.js"></script>
<span id="yammer-login"></span>
<script>
$(function(){

yam.connect.loginButton('#yammer-login', function (resp) {
if (resp.authResponse) {
yam.platform.request({
url: "messages.json",
method: "POST",
data: {
"body" : "Message body",
"group_id": "4728511", //group id
"topic1": "TestTopic1",
"og_url": "http://google.com"
},
success: function (res) { //print message response information to the console
alert("The request was successful.");
console.dir(res);
yam.platform.request({
url: "https://www.yammer.com/api/v1/search.json",
method: "GET",
data: {
"search" : "TestTopic1"
},
success: function (data) { //print message response information to the console
alert("The request was successful.");
console.dir(data);
},
error: function (data) {
alert("There was an error with the request.");
console.log(data)
}
});
},
error: function (res) {
alert("There was an error with the request.");
console.dir(res);
}
});
}
});

状态已在 yammer 上更新,但显示错误,而且我也没有获取主题 ID。那么我该如何纠正它..??

提前致谢

最佳答案

看来您对 search.json 的第二次调用是罪魁祸首。使用 JS SDK 时,您应该直接调用 REST 资源,而不是输入 URL(例如:www.yammer.com 或 api.yammer.com)。

您已经通过第一次调用 messages.json 成功完成了此操作,但应该将第二次调用更新为:

yam.platform.request({
url: "search.json",
method: "GET",
data: {
"search" : "TestTopic1"
},
success: function (data) { //print message response information to the console
alert("The request was successful.");
console.dir(data);
},
error: function (data) {
alert("There was an error with the request.");
console.log(data)
}
});

关于javascript - Yammer REST API 用于创建主题状态并获取主题 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26016935/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com