Advertisement
konradb90

assign-appdata-api

Feb 26th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.69 KB | None | 0 0
  1. /**
  2.  * Endpoint URL
  3.  */
  4. $url = url('api/v2/device/135/appdata/assign');
  5.  
  6. /**
  7.  * First Admin API Key - you should enter your own user api key
  8.  */
  9. $apikey = \User::admins()->first()->apikey->key;
  10.  
  11. $client = new \GuzzleHttp\Client();
  12.  
  13. try {
  14.     $response = $client->request('POST', $url, [
  15.         'headers' => [
  16.             'Accept' => 'application/json',
  17.             'apikey' => $apikey
  18.         ],
  19.         'json' => [
  20.             'data' => [
  21.                 'ports.traffic_ports' => [67, 128]
  22.             ],
  23.         ]
  24.     ]);
  25.  
  26.     $stream = \GuzzleHttp\Psr7\stream_for($response->getBody());
  27.  
  28.     d($stream->getContents());
  29. } catch (\Exception $e) {
  30.     d($e->getMessage());
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement