Skip to content

Instantly share code, notes, and snippets.

@Karasiq
Last active April 7, 2023 20:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Karasiq/16dc180cdbcae2c8ba9bac4295261885 to your computer and use it in GitHub Desktop.
Save Karasiq/16dc180cdbcae2c8ba9bac4295261885 to your computer and use it in GitHub Desktop.
HH.ru resume update script
<?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);
}
}
}
@Karasiq
Copy link
Author

Karasiq commented Oct 26, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment