Closed thaifani closed 4 years ago
I hope you don't really expect me to go through hundreds of lines of unformatted stack traces just to take a guess what the problem might be :). Please at least format code blocks as described for example at https://help.github.com/en/github/writing-on-github/creating-and-highlighting-code-blocks
In general: if you expect to get JSON but instead get HTML, there's probably a problem with the request you're making. Please show me the code (only the relevant parts, and formatted) that you wrote using the SDK that leads to the error.
sorry for that but the response status is OK but response not json this first second when i add to dadabase it worked perfectly but when do messaging return this error message":"SenderId mismatch","code":403,"status_code":500
this my code
public function sendNotification($deviceToken)
{
$firebase = (new Factory)
->withServiceAccount(__DIR__.'/enjeiz-firebase-adminsdk-da7sz-a31e87e601.json')
->withDatabaseUri('https://enjeiz.firebaseio.com/');
$database = $firebase->createDatabase();
$createPost = $database
->getReference('dbnameEx')
->push([
'title' => 'some title',
'body' => 'som body text.'
]);
$resltsend = $createPost->getvalue(); //this worked
$messaging = $firebase->createMessaging();
$message = CloudMessage::withTarget('token', $deviceToken)
->withNotification(Notification::create('someTitle', 'bodyTxt'))
->withData(['firstKey' => 'firstValue']);
$resultMsg = $messaging->send($message);// this return message":"SenderId mismatch","code":403,"status_code":500
...
....
I dont use this library
i use the original https://github.com/kreait/firebase-php
thanks for you time with me the SenderId mismatch error was because the firebase update the keyserver and the devicesTokens was old
Uh, I have the feeling that I didn‘t really help much, next time I‘ll do better! Nonetheless I‘m glad you found the solution and shared it here, this will certainly be useful for others (and I‘ll try to keep it in mind the next time a similar problem occurs).
Thank you! :hibiscus:
we failsKreait\Firebase\Exception\InvalidArgumentException: json_decode error: Syntax error in C:\wamp64\www\meshwari68\vendor\kreait\firebase-php\src\Firebase\Util\JSON.php:63 Stack trace: #0 C:\wamp64\www\meshwari68\vendor\kreait\firebase-php\src\Firebase\Database\ApiClient.php(47): Kreait\Firebase\Util\JSON::decode('...', true) #1 C:\wamp64\www\meshwari68\vendor\kreait\firebase-php\src\Firebase\Database\Reference.php(282): Kreait\Firebase\Database\ApiClient->get(Object(GuzzleHttp\Psr7\Uri)) #2 C:\wamp64\www\meshwari68\vendor\kreait\firebase-php\src\Firebase\Database\Reference.php(247): Kreait\Firebase\Database\Reference->getSnapshot() #3 C:\wamp64\www\meshwari68\app\Http\Controllers\Api\Traits\NotificationTrait.php(266): Kreait\Firebase\Database\Reference->getValue() #4 C:\wamp64\www\meshwari68\app\Http\Controllers\Api\Traits\NotificationTrait.php(93): App\Jobs\SendNotifiNewOrders->sendNotification(Array, Array) #5 C:\wamp64\www\meshwari68\app\Jobs\SendNotifiNewOrders.php(49): App\Jobs\SendNotifiNewOrders->generateNotification('FCMToAllDrivers', 165, NULL, NULL, NULL) #6 [internal function]: App\Jobs\SendNotifiNewOrders->handle() #7 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(32): call_user_func_array(Array, Array) #8 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Container\Util.php(36): Illuminate\Container\BoundMethod::Illuminate\Container{closure}() #9 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(90): Illuminate\Container\Util::unwrapIfClosure(Object(Closure)) #10 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(34): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure)) #11 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Container\Container.php(590): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL) #12 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Bus\Dispatcher.php(94): Illuminate\Container\Container->call(Array) #13 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(130): Illuminate\Bus\Dispatcher->Illuminate\Bus{closure}(Object(App\Jobs\SendNotifiNewOrders)) #14 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(105): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(App\Jobs\SendNotifiNewOrders)) #15 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Bus\Dispatcher.php(98): Illuminate\Pipeline\Pipeline->then(Object(Closure)) #16 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Queue\CallQueuedHandler.php(83): Illuminate\Bus\Dispatcher->dispatchNow(Object(App\Jobs\SendNotifiNewOrders), false) #17 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(130): Illuminate\Queue\CallQueuedHandler->Illuminate\Queue{closure}(Object(App\Jobs\SendNotifiNewOrders)) #18 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(105): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(App\Jobs\SendNotifiNewOrders)) #19 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Queue\CallQueuedHandler.php(85): Illuminate\Pipeline\Pipeline->then(Object(Closure)) #20 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Queue\CallQueuedHandler.php(59): Illuminate\Queue\CallQueuedHandler->dispatchThroughMiddleware(Object(Illuminate\Queue\Jobs\SyncJob), Object(App\Jobs\SendNotifiNewOrders)) #21 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Queue\Jobs\Job.php(88): Illuminate\Queue\CallQueuedHandler->call(Object(Illuminate\Queue\Jobs\SyncJob), Array) #22 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Queue\SyncQueue.php(45): Illuminate\Queue\Jobs\Job->fire() #23 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Queue\SyncQueue.php(151): Illuminate\Queue\SyncQueue->push(Object(App\Jobs\SendNotifiNewOrders), '', NULL) #24 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Bus\Dispatcher.php(179): Illuminate\Queue\SyncQueue->later(Object(Illuminate\Support\Carbon), Object(App\Jobs\SendNotifiNewOrders)) #25 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Bus\Dispatcher.php(158): Illuminate\Bus\Dispatcher->pushCommandToQueue(Object(Illuminate\Queue\SyncQueue), Object(App\Jobs\SendNotifiNewOrders)) #26 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Bus\Dispatcher.php(73): Illuminate\Bus\Dispatcher->dispatchToQueue(Object(App\Jobs\SendNotifiNewOrders)) #27 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Foundation\Bus\PendingDispatch.php(112): Illuminate\Bus\Dispatcher->dispatch(Object(App\Jobs\SendNotifiNewOrders)) #28 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Foundation\helpers.php(392): Illuminate\Foundation\Bus\PendingDispatch->__destruct() #29 C:\wamp64\www\meshwari68\app\Http\Controllers\Api\CustomerRideController.php(211): dispatch(Object(App\Jobs\SendNotifiNewOrders)) #30 [internal function]: App\Http\Controllers\Api\CustomerRideController->orderRide(Object(App\Http\Requests\BookingServiceRequest)) #31 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Routing\Controller.php(54): call_user_func_array(Array, Array) #32 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Routing\ControllerDispatcher.php(45): Illuminate\Routing\Controller->callAction('orderRide', Array) #33 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Routing\Route.php(219): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(App\Http\Controllers\Api\CustomerRideController), 'orderRide') #34 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Routing\Route.php(176): Illuminate\Routing\Route->runController() #35 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Routing\Router.php(681): Illuminate\Routing\Route->run() #36 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(130): Illuminate\Routing\Router->Illuminate\Routing{closure}(Object(Dingo\Api\Http\Request)) #37 C:\wamp64\www\meshwari68\vendor\tymon\jwt-auth\src\Http\Middleware\Authenticate.php(40): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Dingo\Api\Http\Request)) #38 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(171): Tymon\JWTAuth\Http\Middleware\Authenticate->handle(Object(Dingo\Api\Http\Request), Object(Closure)) #39 C:\wamp64\www\meshwari68\app\Http\Middleware\AssignGuard.php(24): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Dingo\Api\Http\Request)) #40 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(171): App\Http\Middleware\AssignGuard->handle(Object(Dingo\Api\Http\Request), Object(Closure), 'rides') #41 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Routing\Middleware\SubstituteBindings.php(41): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Dingo\Api\Http\Request)) #42 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(171): Illuminate\Routing\Middleware\SubstituteBindings->handle(Object(Dingo\Api\Http\Request), Object(Closure)) #43 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Routing\Middleware\ThrottleRequests.php(59): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Dingo\Api\Http\Request)) #44 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(171): Illuminate\Routing\Middleware\ThrottleRequests->handle(Object(Dingo\Api\Http\Request), Object(Closure), 60, '1') #45 C:\wamp64\www\meshwari68\vendor\dingo\api\src\Http\Middleware\PrepareController.php(45): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Dingo\Api\Http\Request)) #46 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(171): Dingo\Api\Http\Middleware\PrepareController->handle(Object(Dingo\Api\Http\Request), Object(Closure)) #47 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(105): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Dingo\Api\Http\Request)) #48 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Routing\Router.php(683): Illuminate\Pipeline\Pipeline->then(Object(Closure)) #49 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Routing\Router.php(658): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Dingo\Api\Http\Request)) #50 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Routing\Router.php(624): Illuminate\Routing\Router->runRoute(Object(Dingo\Api\Http\Request), Object(Illuminate\Routing\Route)) #51 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Routing\Router.php(613): Illuminate\Routing\Router->dispatchToRoute(Object(Dingo\Api\Http\Request)) #52 C:\wamp64\www\meshwari68\vendor\dingo\api\src\Routing\Adapter\Laravel.php(88): Illuminate\Routing\Router->dispatch(Object(Dingo\Api\Http\Request)) #53 C:\wamp64\www\meshwari68\vendor\dingo\api\src\Routing\Router.php(518): Dingo\Api\Routing\Adapter\Laravel->dispatch(Object(Dingo\Api\Http\Request), 'v1') #54 C:\wamp64\www\meshwari68\vendor\dingo\api\src\Http\Middleware\Request.php(126): Dingo\Api\Routing\Router->dispatch(Object(Dingo\Api\Http\Request)) #55 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(130): Dingo\Api\Http\Middleware\Request->Dingo\Api\Http\Middleware{closure}(Object(Dingo\Api\Http\Request)) #56 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Dingo\Api\Http\Request)) #57 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(171): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Dingo\Api\Http\Request), Object(Closure)) #58 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Dingo\Api\Http\Request)) #59 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(171): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Dingo\Api\Http\Request), Object(Closure)) #60 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\ValidatePostSize.php(27): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Dingo\Api\Http\Request)) #61 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(171): Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle(Object(Dingo\Api\Http\Request), Object(Closure)) #62 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode.php(63): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Dingo\Api\Http\Request)) #63 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(171): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Dingo\Api\Http\Request), Object(Closure)) #64 C:\wamp64\www\meshwari68\vendor\fideloper\proxy\src\TrustProxies.php(57): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Dingo\Api\Http\Request)) #65 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(171): Fideloper\Proxy\TrustProxies->handle(Object(Dingo\Api\Http\Request), Object(Closure)) #66 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(105): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Dingo\Api\Http\Request)) #67 C:\wamp64\www\meshwari68\vendor\dingo\api\src\Http\Middleware\Request.php(127): Illuminate\Pipeline\Pipeline->then(Object(Closure)) #68 C:\wamp64\www\meshwari68\vendor\dingo\api\src\Http\Middleware\Request.php(103): Dingo\Api\Http\Middleware\Request->sendRequestThroughRouter(Object(Dingo\Api\Http\Request)) #69 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(171): Dingo\Api\Http\Middleware\Request->handle(Object(Dingo\Api\Http\Request), Object(Closure)) #70 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php(105): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request)) #71 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(145): Illuminate\Pipeline\Pipeline->then(Object(Closure)) #72 C:\wamp64\www\meshwari68\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(110): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request)) #73 C:\wamp64\www\meshwari68\index.php(55): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request)) #74 {main}{"message":"json_decode error: Syntax error","status_code":500}