Yammer的的JavaScript SDK - “访问控制 - 允许 - 原产地”的问题 [英] Yammer JavaScript SDK - 'Access-Control-Allow-Origin' issue

查看:216
本文介绍了Yammer的的JavaScript SDK - “访问控制 - 允许 - 原产地”的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让Yammer的API请求按指令在这里:的https:/ /developer.yammer.com/yammer-sdks/#javascript-sdk 。当我运行这个例子:

I'm trying to make Yammer API request as per instruction here: https://developer.yammer.com/yammer-sdks/#javascript-sdk. When I run this example:

yam.getLoginStatus(
  function(response) {
    if (response.authResponse) {
      console.log("logged in");
      yam.platform.request({
        url: "https://www.yammer.com/api/v1/users.json",     //this is one of many REST endpoints that are available
        method: "GET",
        data: {    //use the data object literal to specify parameters, as documented in the REST API section of this developer site
          "letter": "a",
          "page": "2",
        },
        success: function (user) { //print message response information to the console
          alert("The request was successful.");
          console.dir(user);
        },
        error: function (user) {
          alert("There was an error with the request.");
        }
      });
    }
    else {
      alert("not logged in")
    }
  }
);

我这样做,在本地主机上,我收到以下错误:

I'm doing that on localhost and I'm getting following error:

"XMLHttpRequest cannot load https://www.yammer.com/api/v1/users.json?letter=a&page=2&_=1401954073159. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access."

不知道如何解决这个问题?

Any idea how to solve this?

一件事。因为这调用被执行为选项不是GET请求方法,我不能指定此附加头。

One more thing. I can't specify additional headers in this as this call is executed as 'OPTIONS' not a 'GET' request method.

希望有人有相同的问题,Yammer的最新API,并能解决这个问题。

Hope someone had same issue with Yammer latest API and was able to solve it.

感谢

推荐答案

请务必更新您的Yammer的应用程序的JS起源,以匹配您正在测试环境中的主机名。

Be sure to update your Yammer apps JS Origins to match the environment hostnames that you are testing in.

您可以配置这些起源于这个链接的位置:

You can configure those origins at this link here:

https://www.yammer.com/client_applications

和点击您的应用程序,然后单击基本信息。

And clicking your application, then clicking "Basic Info".

这篇关于Yammer的的JavaScript SDK - “访问控制 - 允许 - 原产地”的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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