Joywork/test_web.php
2026-05-22 21:21:54 +03:00

44 lines
4.2 KiB
PHP
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
require_once($_SERVER['DOCUMENT_ROOT']."/config.php");
ini_set('display_errors', 1);
error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE);
header('Content-Type: application/json');
$content = '{"webhookType":"offersMessages","chats":[{"chatId":236453830,"offerId":329160559,"createdAt":"2026-04-22T20:09:28.351547+00:00","updatedAt":"2026-04-22T20:10:58.245971+00:00","messages":[{"messageId":"78b5ffb6eba728d1504628b51bc6ee3d9883da3f2b5f95400becaea0690e4701","userId":97778260,"userRole":"master","direction":"out","content":{"text":"Спасибо! Обязательно вам перезвоним.","offers":[]},"createdAt":"2026-04-22T20:10:58.245971+00:00"},{"messageId":"fa988fc84f335e23a423857c4e60edd4dbe552ffe516fea22a807de8f71c4c0c","userId":139279206,"userRole":"initiator","direction":"in","content":{"text":"+79921045201\n\n_____\nПодсказки от Циан: \n• Переходить в мессенджеры небезопасно: мы не сможем вас защитить. Помните: если вам пришлют ссылку на оплату через Циан, это мошенники.","offers":[]},"createdAt":"2026-04-22T20:10:58.191930+00:00"}]}],"users":[{"userId":97778260,"name":"M2 Group Недвижимость","avatar":{"images":{"small":"https://www.cian.ru/avatar.axd?i=97778260&t=2&p=1","big":"https://www.cian.ru/avatar.axd?i=97778260&t=2&p=2"}}},{"userId":139279206,"name":"Дхананджай Маурья","firstName":" Дхананджай","lastName":"Маурья","avatar":{"images":{"small":"https://www.cian.ru/avatar.axd?i=139279206&t=2&p=1","big":"https://www.cian.ru/avatar.axd?i=139279206&t=2&p=2"}}}],"offers":[{"id":329160559,"userId":97778260,"url":"https://cian.ru/rent/flat/329160559/","title":"2-комн. кв., 33 м², 3/3 этаж","address":"Ярославская область, Ярославль, улица Закгейма, 26","publishedUserId":98080980,"mainPhoto":{"miniUrl":"https://images.cdn-cian.ru/images/2860018854-3.jpg","url":"https://images.cdn-cian.ru/images/2860018854-1.jpg"},"price":"20 000 ₽/мес.","externalId":"55022470"}]}';
$data = json_decode($content, true);
//var_dump($data);
/*if($_SESSION['id'] == 5238){
$data = json_decode('{"chats":[{"chatId":43117305,"offerId":278723788,"createdAt":"2023-06-15T10:19:48.380579+00:00","updatedAt":"2023-06-15T10:19:49.453829+00:00","messages":[{"messageId":"79cbb860ae2e3e5695bfa57e6e293cbf34a4a81954b3714a300520f66c236c53","userId":68341617,"direction":"in","content":{"offers":[],"text":"Здравствуйте. А есть фото планировки ?"},"createdAt":"2023-06-11T10:19:49.453829+00:00"}]}],"users":[{"userId":68341617,"name":"68341617","avatar":{"images":{"small":"https://www.cian.ru/avatar.axd?i=68341617&t=2&p=1","big":"https://www.cian.ru/avatar.axd?i=68341617&t=2&p=2"}}}],"offers":[{"id":278723788,"userId":12478139,"url":"https://cian.ru/sale/flat/278723788/","title":"4-комн. кв., 127,7 м², 2/7 этаж","address":"Санкт-Петербург, улица Композиторов, 4","publishedUserId":76677006,"mainPhoto":{"miniUrl":"https://cdn-p.cian.site/images/32/558/831/1388552350-3.jpg","url":"https://cdn-p.cian.site/images/32/558/831/1388552350-1.jpg"},"price":"25 700 000 ₽","externalId":"36278839"}]}', true);
var_dump($data);
}*/
$chat = new ChatsCianAvito();
$arrayChat = array();
$arrayChat['chatId'] = $data['chats'][0]['chatId'];
if(empty($arrayChat['chatId'])) die();
$arrayChat['messageId'] = $data['chats'][0]['messages'][0]['messageId'];
$arrayChat['type'] = 'cian';
//$timeZone = 3*3600;
$arrayChat['new'] = 0;
if($data['chats'][0]['messages'][0]['direction'] == 'in'){
$arrayChat['new'] = 1;
}
$arrayChat['object_id'] = $data['offers'][0]['externalId'];
$arrayChat['cian_id'] = $data['offers'][0]['publishedUserId'];
$arrayChat['details'] = $content;
$arrayChat['create_at_original'] = date('Y-m-d H:i:s', (strtotime($data['chats'][0]['createdAt'])));
$arrayChat['update_at_original'] = date('Y-m-d H:i:s', (strtotime($data['chats'][0]['updatedAt'])));
if(isset($agency_id) && (int)$agency_id > 0){
$arrayChat['agency_id'] = (int)$agency_id;
}
//var_dump($arrayChat);
//if($agency_id != 5238){
//$chat->add_message($arrayChat);
//}