Ошибка Yammer Open Graph API 400

Я пытаюсь написать в фид активности Yammer с помощью Open Graph, но получаю ошибку 400 Bad Request. Мне интересно, если URL-адрес или данные неверны.

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" : "[email protected]",
                        "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
            });
        }
    });
}

person kendomen    schedule 09.07.2014    source источник


Ответы (2)


Что ж, у меня это работает:

Создайте страницу Open Graph:

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)
        }
    })

Публикация сообщения на открытой странице графика:

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)
        }
    })
person Raggi    schedule 11.07.2014

У меня была та же ошибка 400. В моем случае решение было очень простым. Я использовал для group_id имя группы, а не group_id.

Вы можете получить group_id, указывающий в вашем браузере на интересующую вас группу. В параметрах URL вы будете иметь:? Type = in_group & feedId = 3028738, feedId - group_id.

Я исправил это и начал отлично работать.

Я не говорю, что это может быть ваш случай, но надеюсь, что это поможет.

person luisfer    schedule 11.02.2015