retrieve people/organization information from linked in - javascript

hi I am involved in a development of web app, where I have to retrieve information of people or organization from linkedin, dynamically.Suppose user A can search for Organization and user B can search for particular person.
I have gone the throough the linked in API's but was not able to figure it out how to implement it.
I am using Linkedin javascript API
Kindly help me

Using the LinkedIn API is a two-step process. First, get the user of your web app to authorize the app to access their LinkedIn information. This means setting up your app on LinkedIn as follows:
https://developer.linkedin.com/apis
Once you have that set-up, you can then query the LinkedIn API using JavaScript (I assume JavaScript is the language/method you want to use, as you tagged it).
You can adjust the results coming back, per the documentation, by using facets and parameters. For instance, to perform a people search that returns all user's named Barack and their profile headline and summary, you'd do something like:
IN.API.PeopleSearch()
.fields(["headline", "summary"])
.params({"first-name":"Barack"})
.result(function(result) {
alert JSON.stringify(result)
})
headline and summary are profile fields that you specify - you can change these to pull the information you need.
Update - including code to perform a company search.
To perform a Company Search using the JavaScript API, you'd use the IN.API.Raw() method:
IN.API.Raw("/company-search:(facets,companies:(id,name,universal-name,website-url))")
.result( function(result) { /* handle result */ } )
.error( function(error) { /* handle error */ } );

Related

How to get avatar for gmail user?

I'm creating an email-based application in React with the Gmail API. I'm loading in a bunch of messages, and I want to display avatars of the senders.
I'm using this package to display avatars. I'd like to either have a Google Id or an image url. It would also be nice to be able to get images for other popular services, such as Outlook and Yahoo mail.
Other people have asked this same question, but all the answers either seem to use the Picasa API (which is deprecated) or the Google+ API (which will be deprecated).
EDIT: Yes, the react-avatar package claims it can find an avatar based on supplied user data, but all it does with the email is find a Gravatar, which many people don't have.
What you want to do is not possible via the GMAIL API or any other Google API
You can not take a Google email address and search for the image or any other personal profile information associated with that email address via any Google API endpoint. Explanation below.
Get image of the sender of an email
Gmail API lists the email messages that have been sent to and by a user. The gmail API is basically returning the mail server email message response in MIME format which if you check does not contain a profile image. It does not return to you the image of a the sender or the reciever.
Google does not have endpoint for developers to use to searching on a gmail.com email address and returning any user profile information (including image) this would be against the users privacy. A user would have to grant you permission to see their image and you dont have that permission for every gmail user who may be sending emails to your authenticated user.
The gmail website probably does some kind of check on gmail email addresses and puts the picture on attached with the account. Google has access to the profile data of all GMAIL users, google cant give you this same access as it would be against the users privacy. If its not a gmail account they may check Gravatar to see if an image has been set up for this email address. Again there is no way for you to request the image of a google user using their email address.
You could check Gravatar to see if one had been set up for that email
If the authenticated user has added this user as a contact and has added a picture for this user you may be able to use the People api.
In the past i have recommend to users that as an image they take the first letter of the users email address and create an image using that letter. You may also want to use a question mark which is actually what gmail does when its website cant find an email from the user probably by checking Gravatar.
Get image of current authenticated user
You can get this information from the people.get endpoint just make sure that you have requested the profile scope from the user when you authenticate them
GET https://people.googleapis.com/v1/people/me
It returns a large response containing the users profile information part of it contains the users picture
"photos": [
{
"url": "https://lh3.googleusercontent.com/a-/AAuE7mDuIWqXzrrp-65cIhXSD2HjCI8WYsWHR0fDx5_wQPY=s100",
"metadata": {
"source": {
"type": "PROFILE",
"id": "117200475532672775346"
},
"primary": true
}
}
],
The offical sample project for people api contains information on how to connect to the api. Just make sure to add the 'profile' scope
The code to get the picture should be something like this.
function getPicture() {
gapi.client.people.people.get({
'resourceName': 'people/me',
'pageSize': 10,
'personFields': 'photos',
}).then(function(response) {
var connections = response.result.connections;
appendPre('Connections:');
if (connections.length > 0) {
for (i = 0; i < connections.length; i++) {
var person = connections[i];
if (person.url && person.url.length > 0) {
appendPre(person.names[0].url)
} else {
appendPre("No display name found for connection.");
}
}
} else {
appendPre('No connections found.');
}
});
}
I don't think that google shares that info with anyone without permission .
You have to create a profile for every user and take the profile image only once when the user registers in your platform by the Google oauth
Check this info
https://developers.google.com/actions/identity/google-sign-in-oauth
The currently accepted answer isn't entirely correct, as there absolutely is a Google API which exposes Gmail Avatars - as well as the user's first- and/or Lastname, as long as the user has configured any publically.
Although I have so far been unable to find the actual API endpoint you can use to achieve this, I did come across avatarapi.com.
As stated on their website:
This API uses public profile information provided by Google, via a publicly exposed Google data source to determine the name and profile image of the user.
They have a fallback to Gravatar. I'd also love to find out where this 'Google Data source' they use is located.
Gravatar
It is possible that the user associated with that email address has signed up for Gravatar. In that case, you can easily obtain the Gravatar avatar.
You need to get the md5 of the email first, then
var email = "youremail#gmail.com",
size = 80;
yourImg.src = 'http://www.gravatar.com/avatar/' + MD5(email) + '.jpg?s=' + size;
https://jsfiddle.net/a4g8s5y2/1/

How to make Google Calendar API Requests using javascript and a service account?

I followed this quickstart tutorial for the Google Calendar API using javascript in my web application. As I need the possibility to show Calendar data on the webpage without user login, I need to implement API calls using a Service Account. Unfortunately I cant't find any good tutorials or explanations for doing so in javascript and since I am fairly new to the subject of API programming I kind of need some guidance.
Ty in advance.
Using Service account on client side is not secure. You may want to switch to a server side implementation for that. Assuming you are familiar with javascript I suggest to follow NodeJS implementation from here.
To create Service Account select service account after step 1->a.
Refer this image for option.
To use Service Account replace the authorize() logic with this
var email = credentials.client_email;
var key = credentials.private_key;
const jwt = new google.auth.JWT(
email, null, key, SCOPES
);
jwt.authorize((err, data) => {
if (err) {
console.error(err);
throw err;
}
console.log('You have been successfully authenticated: ', data);
callback(jwt);
});
As you are using Service Account you also need to create a calendar in your Gmail account to use. Then go to settings and select Add People to share it with client_email from your json, then use your Calendar Id (from Calendar settings) in API Call replacing primary

Use oauth2 to retrieve Google Places client_id

Is it possible to retrieve the Google Places client_id using oauth2? I am able to retrieve Google+ information including the id and Google+ profile url, but I need a way to tie the oauth2 user to the Google Places "client_id".
I have been able to include the Places scope which is listed in the oauth2 popup and asks the user for permission to access the resources, but cannot figure out how to retrieve the authenticated user's client_id.
Scopes:
var scopes = 'https://www.googleapis.com/auth/plus.me https://maps.google.com/maps/feeds/ https://www.googleapis.com/auth/places';
Google+ API Load
Although I can successfully retrieve plus data, the places api does not seem to expose any data. Here is what I have tried:
function makeApiCall() {
/* the plus api does retrieve data, but a similar call to places does not
gapi.client.load('plus', 'v1', function () {
var request = gapi.client.plus.people.get({
'userId': 'me'
});
request.execute(function (resp) {
$(".google-signin").find("img").attr('src', resp.image.url).css('height', '32').css('width', '32');
$("#login-msg").text('Welcome: ' + resp.displayName);
$("img.vote").css('visibility', 'visible');
});
});
*/
gapi.client.load('places', 'v1', function () {
debugger
// the gapi.client does not contain a "places" object
var request = gapi.client.places.get({
'userId': 'me'
});
request.execute(function (resp) {
debugger
});
});
}
Any clarity on this issue is appreciated.
CLARIFICATION EDIT
Perhaps I did not make myself clear. The Google Places API encourages the creation of Events, which are associated with specific Places (of business). We are generating lists based on Google Places API search and details responses (prototype at top-60.bunkerhill.com follow one or more links) We would like businesses to be able to add Events to their associated listing, but cannot allow this without first somehow associating the Places Detail response data with a Google Sign-On; or am I missing something important here?
So the question is "Can a user sign-in to any available Google OAuth API that provides some data which can be used to associate the user with a Places Details entry?
The Google Places API is not the same as the G+ API.
Check out https://developers.google.com/places/documentation/ for instructions on accessing Places data (note that you do not use OAuth for this API - you just include the key from developers.google.com/console in your http request).
Regarding the clarified question: No, the Places API authentication and authorization for creating Events is only via the developer (and your API key), and never the end user who may interact with your application.
For this specific example, you (the developer) can create Events that are associated with a Place, but it would be incumbent on you to make a further association of which end user you wanted to associate with the creation of that Event, and store that metadata within your application if you cared to do so.
Is there a reason having the Places API itself understand this relationship that would be a benefit to your application?

Explain the Facebook access_token

This whole Facebook access_token thing is driving me nuts. All I want to do is fetch a user's public Facebook posts.
It used to work by simply doing:
$.getJSON('http://graph.facebook.com/USERNAME/posts?limit=LIMIT&callback=?', function (posts) {
// Posts available in "posts" variable
});
But now I get the "access_token required" error.
Trust me; I've checked the docs, Googled all over and checked similar questions on SO but I'm really hoping there's a more straight forward way of doing this than what I've seen.
Do you really have to create a Facebook App (I don't even have an account), make the user "accept" the app and login etc for this to work?
With Twitter it's just as easy as it used to be with Facebook.
You really have to create a Facebook App (You need to have an account), make the user "accept" the app and login etc for this to work.
However you can search public posts of user (not a specific user) by facebook's public search api.
e.g.
https://graph.facebook.com/search?q=hello&type=post
This will search all posts with hello keyword in it.
Reference ( you need to have facebook account to see this page )
http://developers.facebook.com/docs/reference/api/
Edit (after seeing comments):
If you want to access public posts of your own page. You can pull it without any login from user (but you will need an access_token)
Generate an offline access_token from here,
http://developers.facebook.com/tools/explorer.
Then you can use that token to pull data . Thus no need of logging on by user.
https://graph.facebook.com/wesellwine/posts?access_token=<access_token from graph api explorer>

How to allow users to see my Google Analytics chart data without undergoing authentication/Sign In process

I am using the Google Analytics Javascript library to let users view a GeoMap of the particular page they are on. However, everytime they attempt to do so, thye have to go through an authentication process only to have my data displayed on my page. How can I find an alternative to this. I only want to embed my Analytics data through a visualized graph on my page so that all anonymous viewers can see it. This is the code where the process takes place.
google.setOnLoadCallback(init);
/**
* This is called once the Google Data JavaScript library has been loaded.
* It creates a new AnalyticsService object, adds a click handler to the
* authentication button and updates the button text depending on the status.
*/
function init()
{
myService = new google.gdata.analytics.AnalyticsService('charts_sample');
/*
this is essentially the line I want to replace. It anonymously
tries to access my viewer's account.I want to set this scope such as it
address the URI of my Analytics account
*/
scope = 'https://www.google.com/analytics/feeds';
/*
if the above scope is altered to my URI then the below unnecessary login
steps will not be required at all. This is the reason why my viewers are
taken to their analytics page which is fundamentally non-existent.
*/
$("authButton").onclick = function() {
// Test if the user is not authenticated.
if (!google.accounts.user.checkLogin(scope))
{
// Authenticate the user.
google.accounts.user.login(scope);
} else
{
// Log the user out.
google.accounts.user.logout();
getStatus();
}
}
getStatus();
}
// gets the account data and then gets the outputs of the requested query
function getStatus()
{
getAccountFeed();
getDataFeed();
}
function getAccountFeed()
{
//Here agsain, I want to modify it access my account's URI
var myFeedUri ='https://www.google.com/analytics/feeds/accounts/default?max-results=50';
myService.getAccountFeed(myFeedUri, handleAccountFeed, handleError);
}
function getDataFeed()
{
var myMapPopularityFeedUri = 'https://www.google.com/analytics/feeds/data?ids=ga%3A53482361&dimensions=ga%3ApagePath%2Cga%3Acity%2Cga%3Acountry%2Cga%3Aregion%2Cga%3Alongitude%2Cga%3Alatitude&metrics=ga%3Avisitors&start-date=2011-12-01&end-date=2011-12-25&max-results=50';
myService.getDataFeed(myMapPopularityFeedUri, handleDataFeed, handleError);
}
Help will be appreciated a lot. Please don't be too critical. Its my first question here. Instead let me know and I will make for my amendments.
Here is a screenshot of what the embed looks like upon my own click, i.e, after GA has
fetched my own data through my account. The geoMap is at the bottom of the page.
It seems the best way is creating of the separate shared (public) feed (report) in Analytics.
Just feed security requires authorization login to view or receive data if the feed (report) was created under personal credentials ... independently to what version OAuth or OAuth2 is used, just if you use request to view data on the site you should use at least API key (for public reports) OR OAuth credentials for personal reports.
look this guide:
Loading an API and Making a Request
or choose any other example from this page:
Google Analytics: Core Reporting API Client Libraries & Sample Code (v3)
Use this nice tool also:
OAuth 2.0 Playground
Generate API key for maps:
Google Maps API Family
Google Maps JS API tutorial:
Google Maps JavaScript API V3
Have you looked at using oAuth2 for the Authorization?

Categories

Resources