How to get the company id from Linkedin Company URL in PHP?
Asked Answered
B

10

6

I have the Linkedin company URL as follows,

http://in.linkedin.com/company/abb

and the company ID for ABB limited is 277579. Essentially you can also reach ABB through http://www.linkedin.com/company/277579.

But if I have only http://in.linkedin.com/company/abb. Is it possible to get the company ID through this URL? Does parsing the URL help? Seeking any good method to get the company ID.

Is there any other way to do without using Linkedin API?

Hope I am clear with my question. Any help would be appreciated.

Baylor answered 10/12, 2012 at 8:34 Comment(7)
developer.linkedin.com/apis See Companies sectionRento
@Dr.Dan thanks. can you help me on how to implement it on PHP?Baylor
Googling how to use the linkedin api php will give plenty of good starting points.Chazan
@Chazan Is linkedin API paid one? It says unauthorized usage all the time.Baylor
Did you register your app? developer.linkedin.com/documents/quick-start-guideChazan
@Chazan No. I dont want to. Its Like I am wondering whether we can parse the result of 'in.linkedin.com/company/abb' to get the company ID.Baylor
No. The API is the only way for a PHP app to get information from linkedin. Like most such sites, they are protecting their data from bots ripping it without permission.Chazan
H
4

Type in your company name in the autocomplete field. Wait until your company name appears as a result. Then click on your company name. Click on Get Code.

<script src="//platform.linkedin.com/in.js" type="text/javascript"> lang: en_US</script>
<script type="IN/FollowCompany" data-id="162479" data-counter="top"></script>

e.g. data-id="162479" is the ID for Apple Company Page

https://developer.linkedin.com/plugins/follow-company

Heinz answered 13/8, 2015 at 0:46 Comment(0)
D
3

I don't know of a way to get this with PHP, so programmatically discovering a company's id may not be an option this way.

However, if you set up a MITM between yourself and LinkedIn.com, you can discover all the network activity between your browser and LinkedIn. A quick way to do this is is by using https://www.owasp.org/index.php/ZAP or http://mitmproxy.org/.

LinkedIn sends the company id of any company page you visit to their ad partners at doubleclick. An example request I discovered is:

https://ad.doubleclick.net/adi/linkedin.dart/biz-overview;optout=false;lang=en;tile=2;sz=300x250;s=0;v=6;u=jDh5sSdmpllmbkt1lndQdCt7;mod=950;title=ic;func=cre;func=edu;coid=744212;coid=2408664;ind=69;ind=80;csize=c;csize=d;occ=290;occ=294;occ=382;pocc=82;pocc=41;pocc=10;zip=20009;cntry=us;reg=97;sub=0;con=j;edu=19947;gy=2011;deg=400;dgcls=200;gdr=m;age=23;seg=773;seg=805;seg=546;seg=1039;seg=683;seg=535;seg=682;seg=1048;seg=748;seg=543;seg=9001;grp=122208;grp=49362;grp=3981403;grp=40456;grp=2229435;sjt=627;sjt=517;sjt=75;fos=100173;fos=100189;company=1273631;tile_p=2;adsuite=v2.2.5-min;sfadapter=t;ord=4824126317418

Within the request parameters, find the "company" param, and its value should be the numeric company id you need:

company=1273631

To verify it is the correct company id, tack it onto the end of a LinkedIn company page:

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

Voila, it works!

Dreyer answered 26/2, 2015 at 20:53 Comment(0)
H
3

You can download the content of site and find

encodeURIComponent('company=12345')

which appears to be valid company id. Just parse it to get ID.

Homesick answered 27/2, 2015 at 16:54 Comment(0)
A
2

a simple way would be to do a file_get_contents on the company page to get the html source and look for "company%3D" and grab the number between that and the next "%"

Agrestic answered 27/2, 2015 at 16:50 Comment(2)
just noticed this question is two years old. sorry.Agrestic
this works well too, much better for a programmatic implementationDreyer
T
1

Why not just hover over the 'follow'/'unfollow' of the company/showcase page, this shows the id in the url ?

Or have I missed something ?

Tremain answered 9/3, 2016 at 12:1 Comment(0)
F
0
<html>
<head>
    <script type="text/javascript" src="http://platform.linkedin.com/in.js">
      api_key: [API KEY]
    </script>       
    <script type="text/javascript">     
        function onGetSuccess(data) {
            console.log(data);              
            for(var i in data.values){
                document.getElementById("company").innerHTML = data.values[i].name + " / " + data.values[i].id;
            }               
        }
        function onError(error) {
            console.log(error);
        }           
        function GetCompanyLinkedIn() {
            var url = "/companies/?/updates/format=json&is-company-admin=true";
            IN.API.Raw(url)     
            .method("GET")
            .result(onGetSuccess)
            .error(onError);            
        }           
    </script>
</head>
<body id="body">
    <div >          
        <script type="IN/Login">
            Hello, <?js= firstName ?> <?js= lastName ?>
            <p id="company" >
                <button type="button" onclick="GetCompanyLinkedIn()">Get company id('s)</button>
            </p>                    
        </script>                   
    </div>      
</body>

Faker answered 29/5, 2015 at 14:30 Comment(0)
F
0

Confirming that Andrew's solution worked. Inside the page source, there are multiple scripts with a company%3... data attribute with the company ID; mine was not visible since the URL was customized.

Fleshly answered 30/6, 2015 at 20:11 Comment(0)
O
0
  1. View page source by pressing ctrl(command)+alt(option/shift)+c
  2. search the page source by pressing ctrl(cmd) + f
  3. input "urn:li:fsd_company:" in the search section and normally the first match will give the company's id(if not,refresh the page)
Overweary answered 29/10, 2022 at 14:18 Comment(0)
V
-1

Hover over the follow button on your company page. https://www.linkedin.com/company/follow/submit?id=6667854&fl=stop&ft=0_Y3kiyf

The ID "6667854"

It works as I followed my company page from another site where it's implemented.

Vegetative answered 2/11, 2016 at 23:2 Comment(1)
he was actually looking for a way to do this in PHP automatically.Ninette
S
-1

try .htaccess file and type the following line

rewriterule ^http://in.linkedin.com/company/abb http://www.linkedin.com/company/277579
Schooling answered 4/4, 2017 at 20:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.