Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get company logo from Linkedin API?

I made a mock company profile on Linkedin & have uploaded two images (see screenshot at bottom of question) and I'm trying to get the second image (large).

I can get the first image using both the logo-url and square-logo-url from the list of Company Profile fields in the Linkedin docs. The info I get back looks like this:

{
    'logoUrl': 'https://media.licdn.com/mpr/mpr/AAEAAQAAAAAAAAagAAAAJDMwYzRhOGVmLWU3MzUtNGUyNi05YTgzLWU3MzVhOGViNGYyZA.png',
    'squareLogoUrl': 'https://media.licdn.com/mpr/mpr/AAEAAQAAAAAAAAS6AAAAJDI4ODQ4NTgxLTQzZGQtNDEzZi1iZjIwLWNiNDgxZTk2NmE5ZA.png',
    'description': "Bla bla",
    etc. etc.
}

The links logoUrl and squareLogoUrl are linked to a square version of the first image.

Does anybody know how I can get the larger image from the Linkedin API? All answers are welcome!

enter image description here

like image 967
kramer65 Avatar asked Jan 12 '16 16:01

kramer65


People also ask

What data can you extract from LinkedIn API?

Using the API for LinkedIn, you can get detailed information about LinkedIn groups based on the ID of the target groups. Below are some of the data you can get: ID, name, date of creation, logo, description, location, industries, etc. Learn more in the LinkedIn API documentation.

How do I integrate LinkedIn API on my website?

Login to the LinkedIn Developer portal. Click My Apps from the top of the page and select Create App. Complete the app details and add your company page. For Self-Serve, complete all the steps and then click the Create App button at the bottom of the page.

How do I use LinkedIn API in Python?

HTTP API exampleSet LINKEDIN_API_KEY and LINKEDIN_API_SECRET, configure your app to redirect to http://localhost:8080/code, then execute: http_api.py. Visit http://localhost:8080 in your browser, curl or similar. A tab in your browser will open up, give LinkedIn permission there.


3 Answers

It is linking to two separate images (the names are not the same). So what I would do is to look at the width and height parameters and see if that is what they are using to make the two images look different. So the first image is say 100x100 but the second is 600x200. Or they might be using one image but the dimensions are different.

I just visited the link you provided. Note the following:

logo-url

URL for the company logo in JPG format.

Your example logo-url says it is PNG.

JPEG(JPG) is used because it doesn't give you jaggies if you increase the size of the image.

Update: Ugh. I looked for some kind of a problem and the answer was right in front of me. Just bring up the page, right-click on the large image, and select "Save Image As..." from the pop-up menu. Since this DOES get you the right image you may have to scrape the HTML source code to find the right image each time (if you are going to do this for multiple companies).

enter image description here

Ok - took me a while to refind the web page you show...

Here is a PHP script that will extract the larger logo for you. All you have to do is to get TO the web page you need to extract it from:

<?php

    $a = file_get_contents( "ztmt.htm" );
    $a = str_replace( chr(13), "", $a );
    $a = str_replace( "<", "\n<", $a );
    $b = explode( "\n", $a );

    foreach( $b as $k=>$v ){
        if( preg_match("/hero-img/i",$v) ){
            $c = explode( " ", $v );
            foreach( $c as $k1=>$v1 ){
                if( preg_match("/\s+src\s*=/i", $v1) ){
                    $d = explode( "=", $v1);
                    $loc = substr( $d[1], 1, -1 );
                    echo "You can get the image from\n\n$loc\n";
                    }
                }
            }
        }
?>

As you can see, I downloaded the HTML source code that displays the web page (you can do that in one line in PHP), it then yanks in the HTML, breaks it up to one HTML command per line, looks for the "hero-img" line, gets the path to that image, and prints it out.

All you have to do is to write a little PHP that sends what company you are looking for to LinkedIn, go to that web page, suck the HTML off (which file_get_contents will do also), and then let the script yank the information out of that web page for you. This DOES NOT fix LinkedIn's mucked up information - it just bypasses it.

As my wife tells her kids at school - When you come to a problem build a bridge and get over it. LinkedIn won't respond - so just grab what you need off of their web pages.

Hopefull this wins me my green checkmark! :-)

BTW: This is called "hero-img" - have you looked to see if there is a tag named that? Just a random thought there. I know it isn't listed - but maybe LinkedIn is as bad about keeping their documentation updated as they are about responding to requests. :-/

I'd also check "hero-url" since everything else is "-url". Just a thought.

like image 151
Mark Manning Avatar answered Oct 22 '22 04:10

Mark Manning


I did a little digging but I can't figure out how on my own. However, I found a thread on this subject that may be useful - but I'm not authorized to look at it, but seems to be for your exact issue. As an active coder for the Developer API, you may have permission. The link is to a forum page and you should see a link to a question titled "Requesting company hero image through API". Let me know if it helps.

like image 26
entpnerd Avatar answered Oct 22 '22 06:10

entpnerd


You cannot do it, becuase the second image depends on how that company designed its page on linkedin.

A company with out second large image,

https://www.linkedin.com/company/ztrdg

A company with second large image as it is not a logo,

https://www.linkedin.com/company/ibm

So that image (large one) is not managed by linkedin, of course you cannot get it from linkedin's api.

The only thing you can do is that resize the logo with a good image library. I suggest the imgscalr in java.

If you want to get big image when it exists, you can use the company url, and get whole html document, then find the url which is in top-image class. And a piece of code:

Document  docu = Jsoup.connect(companyUrl).
            timeout(TIMEOUT).
            userAgent(CRAWLER_NAME).
            get();
Elements elements = document.getElementsByClassName("top-image");
like image 27
ahll Avatar answered Oct 22 '22 06:10

ahll