[英]Linkedin REST API Auth and JSAPI call, Rails/Omniauth
由於這個簡單的問題,幾天前我發脾氣。 你能幫我嗎?
我想,因為它寫在Linkedin JS API文檔中,所以能夠登錄REST並使用JSAPI啟動調用: https : //developer.linkedin.com/documents/inauth-inevent-and-inui
授權令牌
雖然最簡單的驗證JSAPI用戶身份的方法是使用登錄按鈕之一,但是某些站點已經實現了REST API使用的OAuth 1.0a流。 無論您使用哪種身份驗證方式,只要密鑰和主機名相同,JSAPI都會識別出該成員已經登錄。 這是自動發生的,開發人員無需其他代碼。
但這不起作用,我有這個奇怪的控制台錯誤:
Cannot call method 'Profile' of undefined
當我在REST身份驗證后立即調用此命令時:
IN.API.Profile("me").fields(["id", "..."]).result(linkedin_connect_save);
有任何想法嗎?
該控制台錯誤與身份驗證無關-我猜您正在加載另一個JavaScript框架,該框架干擾了LinkedIn框架,並且IN對象未正確加載。
以下頁面與我以前在同一瀏覽器中使用REST進行過身份驗證的密鑰一起使用: http : //developer.linkedinlabs.com/tutorials/testing.html
<html>
<head>
<title>Connections App Example</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body class="yui3-skin-sam yui-skin-sam">
<script type="text/javascript" src="http://platform.linkedin.com/in.js">
api_key: MY_API_KEY
onLoad: loadData
authorize: true
</script>
<script type="text/javascript">
function loadData() {
IN.API.PeopleSearch()
.fields("firstName", "lastName", "distance", "publicProfileUrl","pictureUrl")
.params({"keywords": "princess", "count": 10, "sort": "distance"})
.result(function(result) {
alert(JSON.stringify(result));
});
}
</script>
</body>
</html>
您的代碼可能在js加載之前調用。在您的代碼之前包含js。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.