update_device_example.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. require __DIR__ . '/../config.php';
  3. // 更新 Alias
  4. $result = $client->device()->getDevices($registration_id);
  5. print "before update alias = " . $result['body']['alias'] . "\n";
  6. print 'updating alias ... response = ';
  7. $response = $client->device()->updateAlias($registration_id, 'jpush_alias');
  8. print_r($response);
  9. $result = $client->device()->getDevices($registration_id);
  10. print "after update alias = " . $result['body']['alias'] . "\n\n";
  11. // 添加 tag
  12. $result = $client->device()->getDevices($registration_id);
  13. print "before add tags = [" . implode(',', $result['body']['tags']) . "]\n";
  14. print 'add tag1 tag2 ... response = ';
  15. $response = $client->device()->addTags($registration_id, 'tag0');
  16. print_r($response);
  17. $response = $client->device()->addTags($registration_id, ['tag1', 'tag2']);
  18. print_r($response);
  19. $result = $client->device()->getDevices($registration_id);
  20. print "after add tags = [" . implode(',', $result['body']['tags']) . "]\n\n";
  21. // 移除 tag
  22. $result = $client->device()->getDevices($registration_id);
  23. print "before remove tags = [" . implode(',', $result['body']['tags']) . "]\n";
  24. print 'removing tag1 tag2 ... response = ';
  25. $response = $client->device()->removeTags($registration_id, 'tag0');
  26. print_r($response);
  27. $response = $client->device()->removeTags($registration_id, ['tag1', 'tag2']);
  28. print_r($response);
  29. $result = $client->device()->getDevices($registration_id);
  30. print "after remove tags = [" . implode(',', $result['body']['tags']) . "]\n\n";
  31. // 更新 mobile
  32. $result = $client->device()->getDevices($registration_id);
  33. print "before update mobile = " . $result['body']['mobile'] . "\n";
  34. print 'updating mobile ... response = ';
  35. $response = $client->device()->updateMoblie($registration_id, '13800138000');
  36. print_r($response);
  37. $result = $client->device()->getDevices($registration_id);
  38. print "after update mobile = " . $result['body']['mobile'] . "\n\n";