Ahmed Abdeen
Ahmed Abdeen

Reputation: 356

How to send array of string Guzzle

I want to replace in this code the include_players_ids[] value with array of multiple player ids. I tried body but it says deprecated. Any help please. Guzzle version is 6. I tried ['id', 'id'] and array('id', 'id'). Response is "include_player_ids" should be an array or formatting error

$client = new Client();
    try {

        $r = $client->request('POST', 'https://onesignal.com/api/v1/notifications', [

            'form_params' =>
                [

                'app_id' => 'app_id',

                'include_player_ids[]' => '9cc7691d-04ea-4245-9eed-667f70a218c1',

                'headings' => [
                    'en' => $request->input('title')
                ]
            ]
        ]);

Upvotes: 0

Views: 257

Answers (1)

Thai Nguyen Hung
Thai Nguyen Hung

Reputation: 1232

You can try it:

'form_params' =>
                [

                'app_id' => 'app_id',

                'include_player_ids' => ['9cc7691d-04ea-4245-9eed-667f70a218c1', 'dummy']

                'headings' => [
                    'en' => $request->input('title')
                ]
            ]

http://docs.guzzlephp.org/en/stable/request-options.html#form-params

Upvotes: 1

Related Questions