Yammer的开放图形API错误400 [英] Yammer Open Graph API Error 400

查看:217
本文介绍了Yammer的开放图形API错误400的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想写信给Yammer的活动饲料使用的Open Graph,但我得到400错误的请求错误。我想知道如果URL或数据是错误的。

 函数postToActivity(){
    yam.getLoginStatus(功能(响应){
        如果(response.authResponse){
            yam.request(
              网址:{url:https://api.yammer.com/api/v1/activity.json//注:端点api.yammer ...
              ,方法:POST
              数据:{
                  活动:{
                    演员:{
                        名:肯Domen
                        电子邮件:ken.domen@nike.com
                        行动:像,
                        对象:{
                            URL:http://www.google.com
                            头衔:测试
                         }
                     }
                  }
                }
              ,成功:函数(MSG){
                    警报(后成功!:+ msg.messages [0] .ID); //新的消息的ID
              }
              ,错误:函数(MSG){警报(后是不成功的。+味精); }
              }
            );
        }其他{
            yam.login(功能(响应){
               //没有
            });
        }
    });
}


解决方案

好了,这对我的作品:

创建的Open Graph页面:

  yam.platform.request({
        网址:https://api.yammer.com/api/v1/activity.json
        方法:POST,
        数据:{
            活动:{
                演员:{名:我的名字,电子邮件:我的电子邮件},
                行动:创造,
                对象:{URL:http://google.is,称号:页面标题},
                类型:URL
            }
        },
        成功:函数(RES){
            警报(请求成功);
            console.dir(RES);
        },
        错误:功能(RES){
            警报(有与该请求的错误。);
            的console.log(RES)
        }
    })

留言信息到打开的图形页面:

  yam.platform.request({
        网址:https://api.yammer.com/api/v1/messages.json
        方法:POST,
        数据:{
          身:邮件正文
          GROUP_ID:GRUP编号,即12345678,
          og_url:http://google.is        },
        成功:函数(RES){//打印消息响应信息发送到控制台
            警报(请求成功);
            console.dir(RES);
        },
        错误:功能(RES){
            警报(有与该请求的错误。);
            的console.log(RES)
        }
    })

I'm trying to write to the Yammer Activity Feed using Open Graph but I get 400 Bad Request Error. I'm wondering if the url or data is wrong.

function postToActivity() {
    yam.getLoginStatus( function(response) {
        if (response.authResponse) {
            yam.request(
              { url: "https://api.yammer.com/api/v1/activity.json" //note:  the endpoint is api.yammer...
              , method: "POST"
              , data: {
                  "activity" : {
                    "actor" : {
                        "name" : "Ken Domen",
                        "email" : "ken.domen@nike.com",
                        "action" : "like",
                        "object" : {
                            "url" : "http://www.google.com",
                            "title" : "Test"
                         }
                     }
                  }
                }
              , success: function (msg) {
                    alert("Post was Successful!: " + msg.messages[0].id); //id of new message
              }
              , error: function (msg) { alert("Post was Unsuccessful..." + msg); }
              }
            );
        } else {
            yam.login( function (response) {
               //nothing
            });
        }
    });
}

解决方案

Well, this works for me:

Create an Open Graph page:

yam.platform.request({
        url: "https://api.yammer.com/api/v1/activity.json",
        method: "POST",
        data: {
            "activity": {
                "actor": { "name": "my name", "email": "my email" },
                "action": "create",
                "object": { "url": "http://google.is", "title": "the page title"},
                "type": "url"
            }
        },
        success: function (res) { 
            alert("The request was successful.");
            console.dir(res);
        },
        error: function (res) {
            alert("There was an error with the request.");
            console.log(res)
        }
    })

Post message to the open graph page:

yam.platform.request({
        url: "https://api.yammer.com/api/v1/messages.json",
        method: "POST",
        data: {
          "body" : "Message body",
          "group_id": "grup id, i.e. 12345678",
          "og_url": "http://google.is"

        },
        success: function (res) { //print message response information to the console
            alert("The request was successful.");
            console.dir(res);
        },
        error: function (res) {
            alert("There was an error with the request.");
            console.log(res)
        }
    })

这篇关于Yammer的开放图形API错误400的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆