How can I search Linkedin via PHP?
I have a PHP script that opens http requests with CURL
: (it also accepts a header if needed)
$c = curl_init(); curl_setopt($c, CURLOPT_URL, $url); curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); if ($post_paramtrs) { curl_setopt($c, CURLOPT_POST, TRUE); curl_setopt($c, CURLOPT_POSTFIELDS, "var1=bla&" . $post_paramtrs); } curl_setopt($c, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($c, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; rv:33.0) Gecko/20100101 Firefox/33.0"); curl_setopt($c, CURLOPT_COOKIEJAR, $dirname . 'cookief.txt'); curl_setopt($c, CURLOPT_COOKIEFILE, $dirname . 'cookief.txt'); curl_setopt($c, CURLOPT_MAXREDIRS, 10); $follow_allowed = (ini_get('open_basedir') || ini_get('safe_mode')) ? false : true; if ($follow_allowed) { curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1); } curl_setopt($c, CURLOPT_CONNECTTIMEOUT, 9); curl_setopt($c, CURLOPT_REFERER, $url); curl_setopt($c, CURLOPT_TIMEOUT, 60); curl_setopt($c, CURLOPT_AUTOREFERER, true); curl_setopt($c, CURLOPT_ENCODING, 'gzip,deflate'); $data = curl_exec($c); $status = curl_getinfo($c); curl_close($c);
It works. Now I want to get a linkedin search result. Here is the page you can search for. As you can see it is sending an ajax request to get the data. For example, if you want to find Peter
, it sends this request:
https://www.linkedin.com/voyager/api/typeahead/hits?q=blended&query=Peter
But when you open it manually, it fails and throws this error:
CSRF error.
This means that I have to pass this token along with the request:
What's my question? How can I find this token? Noted that it is not in the DOM. Will it be generated by JS? Anyway, do you have any hints for me?
source to share
No one has answered this question yet
See similar questions:
or similar: