Uzyskanie Zdjęcia Profilowego LinkedIn

Czy jest łatwy sposób na zdjęcie profilowe użytkowników LinkedIn?

Idealnie podobne do tego, jak z Facebook- http://graph.facebook.com/userid/picture

Author: Matt Ball, 2011-08-05

10 answers

Nie tak łatwo... Musisz przejść przez OAuth, następnie w imieniu członka prosisz o:

http://api.linkedin.com/v1/people/{user-id}/picture-url

 30
Author: Adam Trachtenberg,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-10-16 23:46:30

Możesz pobrać oryginalny rozmiar zdjęcia za pomocą tego wywołania:

Http://api.linkedin.com/v1/people/~ / picture-urls:: (original)

Zauważ, że może to być dowolny rozmiar, więc musisz wykonać skalowanie na swojej stronie, ale obraz jest oryginalny przesłany przez użytkownika.

 49
Author: Rahim Basheer,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-01-11 23:15:01

Po uwierzytelnieniu użytkownika Linkedin za pomocą OAuth 2.x jest gotowe, złóż prośbę do adresu URL osób.

Https://api.linkedin.com/v1/people/~:(id,email-address,first-name,last-name,formatted-name,picture-url)?format=json

Gdzie ~ oznacza bieżącego uwierzytelnionego użytkownika. Odpowiedź będzie podobna do tej ...

{
  "id": "KPxRFxLxuX",
  "emailAddress": "[email protected]",
  "firstName": "John",
  "lastName": "Doe",
  "formattedName": "John Doe",
  "pictureUrl": "https://media.licdn.com/mpr/mprx/0_0QblxThAqcTCt8rrncxxO5JAr...cjSsn6gRQ2b"
}
Mam nadzieję, że to pomoże!
 10
Author: Madan Sapkota,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-01-05 07:40:30

Używam OWIN w moim rozwiązaniu, więc po użytkownik pozwala aplikacji używać poświadczeń LinkedIn proste i proste żądanie GET do URL https://api.linkedin.com/v1/people/~: (picture-url)?format = json Jak wyjaśniono wcześniej z autoryzacją na okaziciela w nagłówkach żądań rozwiązałem moje problemy.

Mój Startup.Auth.plik cs
var linkedInOptions = new LinkedInAuthenticationOptions()
{
   ClientId = [ClientID],
   ClientSecret = [ClientSecret],
   Provider = new LinkedInAuthenticationProvider()
   {
      OnAuthenticated = (context) =>
      {
          // This is the access token received by your application after user allows use LinkedIn credentials
          context.Identity.AddClaim(new Claim(
              "urn:linkedin:accesstoken", context.AccessToken));
          context.Identity.AddClaim(new Claim(
              "urn:linkedin:name", context.Name));
          context.Identity.AddClaim(new Claim(
              "urn:linkedin:username", context.UserName));
          context.Identity.AddClaim(new Claim(
              "urn:linkedin:email", context.Email));
          context.Identity.AddClaim(new Claim(
              "urn:linkedin:id", context.Id));

          return Task.FromResult(0);
      }
   }
};

app.UseLinkedInAuthentication(linkedInOptions);

Moja metoda na zdjęcie profilowe użytkownika w LinkedIn:

public string GetUserPhotoUrl(string accessToken)
{
   string result = string.Empty;
   var apiRequestUri = new Uri("https://api.linkedin.com/v1/people/~:(picture-url)?format=json");
   using (var webClient = new WebClient())
   {
      webClient.Headers.Add(HttpRequestHeader.Authorization, "Bearer " + accessToken);
      var json = webClient.DownloadString(apiRequestUri);
      dynamic x = JsonConvert.DeserializeObject(json);
      string userPicture = x.pictureUrl;
      result = userPicture;
   }
   return result;
}

I na koniec fragment mojego działania, który pochłania metodę powyżej:

public async Task<ActionResult> ExternalLoginCallback(string returnUrl)
{
   ...
   var externalIdentity = HttpContext.GetOwinContext().Authentication.GetExternalIdentityAsync(DefaultAuthenticationTypes.ExternalCookie);
   string accessToken =
               externalIdentity.Result.Claims.FirstOrDefault(c => c.Type == "urn:linkedin:accesstoken").Value;
   model.PhotoUrl = GetUserPhotoUrl(accessToken);
   ...
}
Mam nadzieję, że to pomoże. Pozdrawiam
 6
Author: diegosousa88,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-02-21 06:01:09

To działa dobrze dla mnie!

Explained -

Jest to miniaturka z wszystkimi innymi danymi -

https://api.linkedin.com/v1/people/~:(id,location,picture-urls::(original),specialties,public-profile-url,email-address,formatted-name)?format=json

To jest dla oryginalnego obrazu z wszystkimi innymi danymi -

https://api.linkedin.com/v1/people/~:(id,location,picture-url,specialties,public-profile-url,email-address,formatted-name)?format=json

Po prostu użyj picture-urls::(original) zamiast picture-url !

Jest obecnie używany w Gradbee

 3
Author: Siddharth,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-03-24 08:16:24

Po zalogowaniu się do linkedin, otrzymasz accesstoken. Użyj tego tokena dostępu i możesz pobrać dane użytkowników

 LinkedInApiClient client = factory.createLinkedInApiClient(accessToken);
                        com.google.code.linkedinapi.schema.Person person = client.getProfileForCurrentUser(EnumSet.of(
                                ProfileField.ID, ProfileField.FIRST_NAME, ProfileField.LAST_NAME, ProfileField.HEADLINE,
                                ProfileField.INDUSTRY, ProfileField.PICTURE_URL, ProfileField.DATE_OF_BIRTH,
                                ProfileField.LOCATION_NAME, ProfileField.MAIN_ADDRESS, ProfileField.LOCATION_COUNTRY));
    String imgageUrl=person.getPictureUrl();
 2
Author: Kimmi Dhingra,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-01-03 10:55:19

Jeśli twoim celem jest po prostu wyświetlenie zdjęcia na swojej stronie, Wtyczka LinkedIn Member Profile może Ci się udać. Wyświetli zdjęcie, dodatkowe informacje wraz z brandingiem LinkedIn.

Ponieważ API LinkedIn jest przeznaczone do użytku wyłącznie w imieniu bieżącego zalogowanego użytkownika, nie oferuje podobnej funkcjonalności jak API facebook graph.

 1
Author: Hoodah,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-04-14 18:49:26

To jest moje rozwiązanie i działa bardzo dobrze:

def callback(self):
    self.validate_oauth2callback()
    oauth_session = self.service.get_auth_session(
        data={'code': request.args['code'],
              'grant_type': 'authorization_code',
              'redirect_uri': self.get_callback_url()},
        decoder=jsondecoder
    )
    me = oauth_session.get('people/~:(id,first-name,last-name,public-profile-url,email-address,picture-url,picture-urls::(original))?format=json&oauth2_access_token='+str(oauth_session.access_token), data={'x-li-format': 'json'}, bearer_auth=False).json()
    social_id = me['id']
    name = me['firstName']
    surname = me['lastName']
    email = me['emailAddress']
    url = me['publicProfileUrl']
    image_small = me.get('pictureUrl', None)
    image_large = me.get('pictureUrls', {}).get('values', [])[0]
    return social_id, name, surname, email, url, image_small, image_large, me
 1
Author: piezzoritro,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-02-05 13:00:01

Dla mnie to działa

Image = auth.extra.raw_info.zdjęcie.wartości.ostatni.pierwszy

Z omniauth-linkedin gem

 0
Author: sparkle,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2015-02-05 10:10:58

To może nie jest to, o co prosisz, ale jest przydatne w indywidualnych śledztwach.

Wywołanie strony w Firefoksie, kliknij lewym przyciskiem myszy menu nad obrazem tła. Wybierz Element Inspect (Q).

Search for-target-image" Będzie to koniec atrybutu id w elemencie img. Atrybut src tego elementu img będzie adresem URL obrazu tła.

 0
Author: Robin Hodson,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2017-01-22 07:08:18