-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
44 lines (38 loc) · 1.29 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
include_once("vendor/autoload.php");
use GuzzleHttp\Client;
use GuzzleHttp\Exception\ClientException;
$baseUrl = "https://api.hh.ru";
$client = new Client([
// Base URI is used with relative requests
'base_uri' => $baseUrl,
'timeout' => 2.0,
]);
$token=file_get_contents('https://opendevelopers.ru/getKey.php');
$headers=[
'headers' => [
'User-Agent' => 'Letunovskiymn/1.0 ([email protected])',
'Accept' => '*/*',
'Authorization' => 'Bearer '.$token
]
];
$response = $client->request('GET', '/resumes/mine', $headers);
if ($response->getStatusCode() == 200){
$data=json_decode($response->getBody(),true);
foreach ($data['items'] as $resume){
$date=new DateTime();
$idResume=$resume['id'];
try {
$responseResume = $client->request('POST', '/resumes/'.$idResume.'/publish', $headers);
if ($responseResume->getStatusCode()==204){
//very good
file_put_contents('log.txt',$date->format('d-m-Y H:i:s')."\n".
$responseResume->getBody()."\n", FILE_APPEND);
}
}
catch (ClientException $e){
file_put_contents('log.txt',$date->format('d-m-Y H:i:s')."\n".
$e->getMessage()."\n", FILE_APPEND);
}
}
}