Last active
April 7, 2023 20:51
-
-
Save Karasiq/16dc180cdbcae2c8ba9bac4295261885 to your computer and use it in GitHub Desktop.
HH.ru resume update script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$client_id = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; | |
$client_secret = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; | |
if (empty($_GET['code'])) { | |
echo '<p><a href="https://hh.ru/oauth/authorize?response_type=code&client_id=' . $client_id . '">Обновить резюме</a></p>'; | |
} else { | |
if ($curl = curl_init()) { | |
curl_setopt($curl, CURLOPT_URL, 'https://hh.ru/oauth/token'); | |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($curl, CURLOPT_POSTFIELDS, "grant_type=authorization_code&client_id=" . $client_id . "&client_secret=" . $client_secret . "&code=" . $_GET['code']); | |
$out = curl_exec($curl); | |
curl_close($curl); | |
} | |
$token_json = json_decode($out); | |
$headers = array( | |
'Authorization: Bearer ' . $token_json->access_token, | |
'User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.102 Safari/537.36' | |
); | |
if ($curl = curl_init()) { | |
curl_setopt($curl, CURLOPT_URL, 'https://api.hh.ru/resumes/mine'); | |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); | |
$out = curl_exec($curl); | |
curl_close($curl); | |
} | |
$resumes = json_decode($out); | |
foreach ($resumes->{'items'} as $item) { | |
if ($curl = curl_init()) { | |
curl_setopt($curl, CURLOPT_URL, 'https://api.hh.ru/resumes/' . $item->id . '/publish'); | |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($curl, CURLOPT_POST, true); | |
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); | |
$out = curl_exec($curl); | |
echo $out; | |
curl_close($curl); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://masterpro.herokuapp.com/hh/index