S
S
Shane Matte2017-01-15 02:10:39
PHP
Shane Matte, 2017-01-15 02:10:39

Why doesn't it send data to the server when the array is generated?

Hello. I ran into a problem and I don't understand what is wrong.
I send push by user id. IDs are stored in the database. I select from a DB, I bring in an array.

$pushUsersId = [];
                $searchUserspushTable = push_users::whereIn('user_id',$usersId)->get();
                foreach($searchUserspushTable as $searchUserpushTable){
                    $pushUsersId[] = $searchUserpushTable->push_id;
                }

I put the array into the $fields variable and do the mailing
$fields = array(
                        'app_id' => "09439242-d8c7-45e2-a3c5-7caa2f17cf30",
                        'include_player_ids' => $pushUsersId,
                        'contents' => $content,
                        'headings' => $headings
                    );

But there are no push notifications. But if I enter the IDs into the variable directly, everything works.
$pushUsersId = array('6e6c8648-fcaa-4c25-9ac1-4f64f8484985','5fe0b8c3-7485-4ce2-875d-405fc78b967a');
                    $fields = array(
                        'app_id' => "09439242-d8c7-45e2-a3c5-7caa2f17cf30",
                        'include_player_ids' => $pushUsersId,
                        'contents' => $content,
                        'headings' => $headings
                    );

Where did I go wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Georg, 2017-01-15
@Georg

$pushUsersId[] = $searchUserpushTable->push_id;
Try to do it instead

$pushUsersId[] = (string) $searchUserpushTable->push_id;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question