Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Список пользователей, которых нужно импортировать
- # Первый элемент - User ID из вашей системы
- $users = array(
- array('id' => 123,
- 'email' => 'mail1@mail.ru',
- 'phone' => '891xxxxxx',
- 'name' => 'Test'
- ),
- array('id' => 456,
- 'email' => 'mail2@mail.ru',
- 'phone' => '891xxxxxx',
- 'name' => 'Test2'
- )
- );
- $auth_token = 'xxx' # TODO: ПОДСТАВЬТЕ СЮДА ВАШ AUTH_TOKEN, его можно найти в разделе Настройки > API КЛЮЧИ
- for ($i =0; $i < count($users); ++$i ) {
- $url = 'http://api.carrotquest.io/v1/users/'.$users[$i]['id'].'/props?auth_token='.$auth_token;
- $operations = json_encode(array(
- array('op' => 'update_or_create',
- 'key' => '$email',
- 'value' => $users[$i]['email']
- ),
- array('op' => 'update_or_create',
- 'key' => '$phone',
- 'value' => $users[$i]['phone']
- ),
- array('op' => 'update_or_create',
- 'key' => '$name',
- 'value' => $users[$i]['name']
- ),
- )
- );
- $result = file_get_contents($url, false, stream_context_create(array(
- 'http' => array(
- 'method' => 'POST',
- 'header' => 'Content-type: application/x-www-form-urlencoded',
- 'content' =>http_build_query(array('operations' => $operations,'by_user_id' => 'true')),
- )
- )));
- print $result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement