LinkedIn API calling in Javascript - linkedin-api

I have used the LinkedIn Javascript API calls in my html page. I can see the "Sign In With LinkedIn" button . In "onLinkedInLoad" function calling the "IN.Event.on("IN", "auth", onLinkedInAuth);" is not firing. I have an alert message 'call2' in my code and its also not calling.
Basically I want to read a company updates and bind into a div. In Browser console I am getting the below URL and profile's response. There is no other request in browser console.
https://api.linkedin.com/v1/people::(~):(id,first-name,last-name,headline,picture-url)
I followed all the instructions in LinkedIn document before doing this to consume a company update.
I have a company page and with an update.
I have created an app and use that api key only in js function call.
In LinkedIn REST Console I can see my update.
Do I miss anything ? Thanks.
I use the actual api key and company id at my end.
See my code :
<html>
<head>
<title>
LinkedIn
</title>
<script type="text/javascript" src="https://platform.linkedin.com/in.js">
api_key: 0000000000000
onLoad: onLinkedInLoad
authorize: true
</script>
<script type="text/javascript">
function onLinkedInLoad() {
alert('call');
IN.Event.on("IN", "auth", onLinkedInAuth);
}
function onLinkedInAuth() {
alert('call2');
IN.API.Raw("/companies/000000/updates")
.method("GET")
.result(function(res) {
document.write(JSON.stringify(res));});
}
</script>
</head>
<body>
<script type="IN/Login">
</script>
</body>
</html>

I have used IN.User.authorize(onLinkedInAuth) instead of IN.Event.on("IN", "auth", onLinkedInAuth) for authorization and worked.

Related

Create a Shopify Page that Redirects to Mailto

i'm trying to create a shopify page link that will redirects to the mailto. When the user visit the page, it will automatically run the mailto:EmailAddress
A mail-to link is something like:
Send Mail
To function to do it programmatically is:
<script>
function mailto()
{
window.location.href = "mailto:someone#example.com?Subject=Hello";
}
</script>
To run the function automatically:
<body onload="javascript: mailto();">
or
<script>
mailto();
</script>

Facebook page post as admin using javascript api

I do lots of stuff in my javascript code for posting feed in page as m`, but how i can get permission through javascript with just one click.
This is my code.
<body>
<div id='fb-root'></div>
<script src='http://connect.facebook.net/en_US/all.js'></script>
<p>
<a href="javascript:;" onclick='postToFeed(); return false;'>Post to Group</a>
</p>
<p id='msg'></p>
<script>
FB.init({appId: "apid", status: true, cookie: true});
function postToFeed() {
FB.api('/page_id/feed', 'post',
{
message : "It's awesome ...",
link : 'http://csslight.com',
picture : 'http://csslight.com/application/upload/WebsitePhoto/567-grafmiville.png',
name : 'Featured of the Day',
from: 'pageid',
description : 'CSS Light is a showcase for web design encouragement, submitted by web designers of all over the world. We simply accept the websites with high quality and professional touch.'
},
function(response) {
alert(JSON.stringify(response));
});
}
</script>
</body>
Output of above script is
But i wan't to post as a BeCrazzy.com not Rajnish..!
simply, i want to post feed in page as a admin. please help me. :)
There is a tutorial here that shows you exactly how to do this:
https://developers.facebook.com/docs/howtos/login/login-as-page/
You will not be able to use the Facebook Javascript SDK to make the API call signed with the Page access token, you'll need to use something like jQuery.ajax() to do so.

Facebook login, redirect_uri is not owned by the application. why?

I can't add FB login to my site. I simply registered the application:
URL: http://www.chusmix.com/
DOMAIN: www.chusmix.com
And then I pasted the login code and replaced my APP id in it:
<html>
<head>
</head>
<body>
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
appId:'212044715486306', cookie:true,
status:true, xfbml:true
});
</script>
<fb:login-button>Login with Facebook</fb:login-button>
</body>
</html>
However when clicking the login button I get Error 191: redirect_uri is not owned by the application
Also this code is in the page: http://www.chusmix.com/game/ according to what Facebook says filling the field DOMAIN makes all pages in the domain able to use Facebook Authorization. However I also tried pointing directly to the domain where the Login Button is and I get the same error.
There isn't even a redirect url.
Update: It seems the Login works in http://www.chusmix.com/game/ but doesn't on http://chusmix.com/game/ (without www).
Is there a way to make it work if the user doesn't type www.? Or do I have to use a redirect?
Try adding the site URL to the app settings Edit Settings->Web Site->Site URL. While you are there you might as well fill in the Site Domain in case you add sub domains in the future.
Use this as you Site Domain: chusmix.com
Make sure every URL in your JS script matches EXACTLY to the Site URL you set up in Facebook, including http://.
Ex:
FB.init({
appId : '128957350986', // App ID
channelUrl : 'zazzlebaytobreakers.com/lib/channel.php', // Channel File
Will cause this error in IE 7 and 8.
Make sure it's:
FB.init({
appId : '128957350986', // App ID
channelUrl : 'http://zazzlebaytobreakers.com/lib/channel.php', // Channel File

Facebook Like notifications?

I saw a website today that stated: "Share/Like this site and get 10% discount". I was wondering: is there any way to track when someone shares/likes my site? Can I store some data of that user in my app?
I know those events have some callbacks, and maybe I can trigger some jQuery magic to send some data vía ajax when the user clicks on the button.
Any ideas?
Thanks!
Similar question was discussed here
FB.Event.subscribe('edge.create', function(href)
{
});
From the above code you can get only href not any User details. So I tired the following code
FB.Event.subscribe('edge.create', function (href) {
FB.login(function (response) {
if (response.session) {
//session object has uid & access token.
}
});
});
The Problem you will have from above code is: Since FB.login will open a pop up window for log in, some browsers will block the pop up or warns the user.
I tried the above code. LIKE functionality works and is posted to user's wall, but regarding getting user info:
Firefox (4.0) - did not warn but it asked the user to authorize APP and access basic information. IE 9 - Gave a warning message about POP UP. Google Chrome : Blocked the log in pop up.
It seems the only way to achieve this is let the user login to website using Facebook Connect first and then get user info using
FB.Event.subscribe('edge.create', function (href) {
// href is the URL of the object that got liked
var x;
FB.getLoginStatus(function (response) {
alert(response);
if (response.session) {
}
});
Check out the Facebook developers site. It contains heaps of information.
http://developers.facebook.com/search?q=Events.create
and
http://developers.facebook.com/blog/post/149/
Something like this should do what you need:
<fb:like href="http://www.google.com"></fb:like>
<!-- Like button to whatever object you want^^ -->
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"
type="text/javascript" charset="utf-8"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"
type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
FB.init({
appId: 'APP_ID',
status: true,
cookie: true,
xfbml: true
});
FB.Event.subscribe('edge.create', function(href)
{
// href is the URL of the object that got liked
// do whatever magic ajax you want
});
</script>

Connect to Facebook with Javascript Client Library using Adobe AIR

I'm having an issue connecting to Facebook through the Javascript Client Library in Adobe AIR. It works fine in the browser but in Adobe AIR it seems to not be able to find the Facebook functions. Here is some code I copied from the Facebook website: (Oh and I have the xd_receiver.htm file in the correct path too)
<textarea style="width: 1000px; height: 300px;" id="_traceTextBox">
</textarea>
<script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script>
//
var api = FB.Facebook.apiClient;
// require user to login
api.requireLogin(function(exception){
FB.FBDebug.logLevel=1;
FB.FBDebug.dump("Current user id is " + api.get_session().uid);
// Get friends list
//5-14-09: this code below is broken, correct code follows
//api.friends_get(null, function(result){
// Debug.dump(result, 'friendsResult from non-batch execution ');
// });
api.friends_get(new Array(), function(result, exception){
FB.FBDebug.dump(result, 'friendsResult from non-batch execution ');
});
});
});
//]]>
</script>
It's not that simple actually man, the problem with loading external script files from the application sandbox is that it's not supported. Technically, by using iframes, you should be able to do this and it works but it's still impossible to use XFBML in the root document after from my experience. After two days of trial and error, the easiest way to do use Facebook Connect in an html/ajax adobe air application is to download the actionscript library and include it as such:
<script type="application/x-shockwave-flash" src="lib/facebook.swf"></script>
<script type="text/javascript">
var FB = window.runtime.com.facebook;
var fb = new FB.Facebook();
var session = new FB.utils.DesktopSessionHelper();
//etc...
</script>
then just refer to the documentation. my only problem now it that I still haven't found an efficient enough way of using XFBML in adobe air, simply adding the facebook namespace to the html tag doesn't do the trick unfortunately. If any knows, please do share thanks
you also need to change xml namespace (main html tag) to this:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml" xml:lang="en-gb" lang="en-gb">