GithubHelp home page GithubHelp logo

Internal server error about php-fcm HOT 6 CLOSED

edwinhoksberg avatar edwinhoksberg commented on September 6, 2024
Internal server error

from php-fcm.

Comments (6)

mhd-yasser-haddad avatar mhd-yasser-haddad commented on September 6, 2024 1

It turns out that the problem was from the server ports and IP because there are specific ports that the firebase need to use to send notifications from.
Thank you for your help.
Here are the links that helped discover the problem:
https://firebase.google.com/docs/cloud-messaging/concept-options
https://support.fitnessondemand247.com/hc/en-us/articles/360007883114-Firewall-and-Network-Port-Rules

from php-fcm.

rolinger avatar rolinger commented on September 6, 2024

@mhd-yasser-haddad - you will need to post a bit more info. What is your config...what are your paths to the php-fcm project, etc? What is your script referencing? etc.

from php-fcm.

mhd-yasser-haddad avatar mhd-yasser-haddad commented on September 6, 2024

so I have this function inside a class that sends the notification:
//////////////////////////////
/////////////////////////////
public static function sendNotification($title, $body, $deviceToken, $data)
{

    // Instantiate the client with the project api_token and sender_id.
    $client = new \Fcm\FcmClient(SELF::$serverKey, SELF::$senderId);

    // Instantiate the push notification request object.
    $notification = new \Fcm\Push\Notification();

    $notification
        ->addRecipient($deviceToken)
        ->setTitle($title)
        ->setBody($body);
    foreach ($data as $key => $value)
        $notification->addData($key, $value);

    // Send the notification to the Firebase servers for further handling.
    $response = $client->send($notification);
    return $response;
}

//////////////////////////////
/////////////////////////////
I ran this code on my localhost and everything was going well, then I uploaded the code to the server and it stopped working and it kept giving me (500 internal server error).
Note that I tried to put echo and die statements in this code and everything was fine before the
"$response = $client->send($notification);"
and when I put it after this statement in got me an internal server error.

Thank you in advance

from php-fcm.

rolinger avatar rolinger commented on September 6, 2024

@mhd-yasser-haddad - Internal server error 500 typically means your code has errored out. Go to the folder with the script in it and check the error_log to see if there is anything telling you whats wrong. If you don't see anything try a manual execution of the file from the command line and check error_log again. I suspect your paths to the FCM-PHP are not correct.

from php-fcm.

mhd-yasser-haddad avatar mhd-yasser-haddad commented on September 6, 2024

I tried to look for the error log file but I was unable to locate it, But I tried to use and call this function on the local server and everything ran okay, and I think that if the problem was from the directories the initialise of the $client and $notification variables wouldn't work out? don't you think?

from php-fcm.

rolinger avatar rolinger commented on September 6, 2024

unless you post actual technical stuff, not certain there is much anyone can do assist you.

from php-fcm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.