public function __get($name)
{
if (!isset($this->data[$name])) {
throw new Exception('There is no column "' . $name . '"');
}
return $this->data[$name];
}
echo $items->title;
class MyItem
{
protected $data = [];
public function __construct($data = [])
{
$this->data = $data;
}
public function only($keys)
{
$data = [];
foreach ($keys as $key) {
$data[$key] = $this->data[$key];
}
return $data;
}
public function __set($name, $value)
{
return;
}
public function __get($name)
{
if (!isset($this->data[$name])) {
throw new Exception('There is no column "' . $name . '"');
}
return $this->data[$name];
}
}
public function getItem($id)
{
$response = @json_decode($this->request('GET', 'https://site.ru/json=' . $id)['body'], true);
var_dump($this->request('GET', 'https://site.ru/json=test@test.ru'));
array(6) {
["http_code"]=>
int(200)
["raw_response"]=>
string(187) "HTTP/1.1 200 OK
Server: nginx
Date: Mon, 19 Aug 2019 21:31:22 GMT
Content-Type: application/json;charset=utf-8
Content-Length: 28
Connection: keep-alive
Content-Encoding: gzip
[]"
["header_size"]=>
int(185)
["header"]=>
string(185) "HTTP/1.1 200 OK
Server: nginx
Date: Mon, 19 Aug 2019 21:31:22 GMT
Content-Type: application/json;charset=utf-8
Content-Length: 28
Connection: keep-alive
Content-Encoding: gzip
"
["headers"]=>
array(7) {
[0]=>
string(15) "HTTP/1.1 200 OK"
[1]=>
string(13) "Server: nginx"
[2]=>
string(35) "Date: Mon, 19 Aug 2019 21:31:22 GMT"
[3]=>
string(44) "Content-Type: application/json;charset=utf-8"
[4]=>
string(18) "Content-Length: 28"
[5]=>
string(22) "Connection: keep-alive"
[6]=>
string(22) "Content-Encoding: gzip"
}
["body"]=>
string(2) "[]"
}
[{"isTrue":true,"price":{"value":3490.0,"currency":"USD"................} ]
{"isTrue":true,"price":{"value":3490.0,"currency":"USD"................}
$response = @json_decode($this->request('GET', 'https://site.ru/json=111')['body'], true);
$response = @json_decode($this->request('GET', 'https://site.ru/json=test@test.ru')['body'], true);
$response = @json_decode($this->request('GET', 'https://site.ru/json=' . $id)['body'], true);
$response = $this->request('GET', 'https://site.ru/json=' . $id['body'], true);
object(MyItem)#120 (1) { ["data":protected]=> NULL }
object(MyItem)#120 (1) { ["data":protected]=> array(0) { } }
public function getItem($id)
{
$response = @json_decode($this->request('GET', 'https://site.ru/json=' . $id)['body'], true);
var_dump ($this->request);
.........
[{"isTrue":true,"price":{"value":3490.0,"currency":"USD"................} ]
За один запрос, получаю 10 ответов.
Думаю в течении 10 минут, ответ сильно не изменится, крон буду выполнять раз в 10 минут.
Но мне интересно, скрипт за 10 минут успеет найти соответствие email из json с email из базы?
Дергать собирался по id, вернее проверять, есть ли в базе эти данные или нет, это после того, как нашелся email, т. е., чтобы не дублировать данные.
Пользователей будет до 10 000
3 пункт самый сложный получается, найти email и сравнить с базой + проверку выполнить по id, чтобы повторно не сохранить те же данные.