我想在网站上显示我自己帐户的推荐。
<script type="text/javascript" src="http://platform.linkedin.com/in.js">
api_key: xxxx
onLoad: onLinkedInLoad
authorize: false
</script>
<script type="text/javascript">
function onLinkedInLoad(){
var target = $("#recommendation");
IN.API.Raw("people/~:(id,first-name,last-name,recommendations-received)").method("GET").result(function(result){
console.log("result",result);
for(var key in result.values) {
var recommendation = result.values[key];
target.append($(recommendation.recommender.firstName + recommendation.recommender.lastName + recommendation.recommendationText));
}
});
}
</script>
然而,当我加载页面时,我得到:
Blocked a frame with origin "https://api.linkedin.com" from accessing a frame with origin "http://127.0.0.1". The frame requesting access has a protocol of "https", the frame being accessed has a protocol of "http". Protocols must match.
GET https://api.linkedin.com/v1/people/~:(id,first-name,last-name,recommendations-received) 404 (Not Found)
XHR finished loading: "https://api.linkedin.com/v1/people/~:(id,first-name,last-name,recommendations-received))".
有谁知道我哪里出错了? 我得到同样的授权设置为true或false,理想情况下我不想要求登录,只需从我自己的个人资料中显示。
答案 0 :(得分:0)
在我的网站上集成LinkeIn身份验证时遇到了同样的问题。
虽然它没有阻止linkedin api工作,但我很生气地看到控制台上出现错误。所以我绑定了一个监听器,以便在加载之前删除来自“https://api.linkedin.com”的任何iframe。
jQuery('body').bind("DOMSubtreeModified", function(evt) {
var elemento=evt.delegateTarget.lastChild;
if(elemento.tagName=='IFRAME') {
if(elemento.src.indexOf('https://api.linkedin.com')!=-1) {
jQuery('#'+elemento.id).remove();
}
}
});
一切仍然有效。