OneSignal\OneSignal::request PHP Method

request() public method

Make a custom api request.
public request ( string $method, string $uri, array $headers = [], string | Psr\Http\Message\StreamInterface | null $body = null ) : array
$method string HTTP Method
$uri string URI template
$headers array
$body string | Psr\Http\Message\StreamInterface | null
return array
    public function request($method, $uri, array $headers = [], $body = null)
    {
        try {
            $response = $this->client->send($method, self::API_URL . $uri, array_merge(['Content-Type' => 'application/json'], $headers), $body);
            return json_decode($response->getBody(), true);
        } catch (\Throwable $t) {
            throw new OneSignalException($t->getMessage());
        } catch (\Exception $e) {
            throw new OneSignalException($e->getMessage());
        }
    }

Usage Example

コード例 #1
0
 /**
  * Export all information about devices in a CSV format for your application.
  *
  * Application auth key must be set.
  *
  * @return array
  */
 public function csvExport()
 {
     return $this->api->request('POST', '/players/csv_export', ['headers' => ['Authorization' => 'Basic ' . $this->api->getConfig()->getApplicationAuthKey()], 'json' => ['app_id' => $this->api->getConfig()->getApplicationId()]]);
 }
All Usage Examples Of OneSignal\OneSignal::request