-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_contact.php
More file actions
executable file
·44 lines (32 loc) · 943 Bytes
/
update_contact.php
File metadata and controls
executable file
·44 lines (32 loc) · 943 Bytes
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
#!/usr/bin/php
<?php
require 'vendor/autoload.php';
function update_contact(string $mdn, array $options)
{
$session = new ScgApi\Session($options);
$res = new ScgApi\ContactResource($session);
$contactId = $res->create([
'first_name' =>'John',
'last_name' => 'Doe',
'primary_mdn' => $mdn
])['id'];
$contact = $res->get($contactId);
$res->update($contactId, [
'last_name'=>'Anderson',
'version_number' => $contact['version_number']
]);
$contact = $res->get($contactId);
echo "John Doe changed name to ${contact['first_name']} ${contact['last_name']}";
echo PHP_EOL;
$res->delete($contactId);
}
if (sizeof($argv) < 2) {
echo 'Usage: update_contacts.php auth-file mdn [api-url]' . PHP_EOL;
exit(-1);
}
$options['auth'] = $argv[1];
if (!empty($argv[3])) {
$options['base_uri'] = $argv[3];
}
update_contact($argv[2], $options);
?>