Saturday, July 17, 2021

curl request example

  $data = [

"registration_ids" => $firebaseToken,

"notification" => [

"title" => $request->title,

"body" => $request->body,

]

];

$dataString = json_encode($data);

$headers = [

'Authorization: key=' . $SERVER_API_KEY,

'Content-Type: application/json',

];

    Example 1:

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send');

curl_setopt($ch, CURLOPT_POST, true);

curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

curl_setopt($ch, CURLOPT_POSTFIELDS, $dataString);

$response = curl_exec($ch);


      Example 2:

 
      curl --request POST \
--url http://localhost:8000/api/login \
--header 'Accept: aplication/json' \
--header 'Content-Type: application/json' \
--data '{
"email":"user@hydra.project",
"password":"Surprisingly A Good Password"
}'


 Example 3:
curl --request GET \
--url http://localhost:8000/api/greet \
--header 'Accept: application/json' \
--header 'Authorization: Bearer 5|gbiWdd7yJFYiTIgoK1jK3C7HZJtJUK1PnBIToBLN

        

No comments:

Post a Comment