GCM sending with curl (php)

前端 未结 2 1960
无人及你
无人及你 2020-12-10 22:52

I\'m trying to send a message to an Android phone but keep getting response code 401 with text: Unauthorized. Also I keep reading different stories on what key to use, I kno

相关标签:
2条回答
  • 2020-12-10 23:14

    I changed the header to:

    $headers = array("Content-Type:" . "application/json", "Authorization:" . "key=" . "mykey");
    

    And it works. The mykey is Key for browser apps.

    0 讨论(0)
  • 2020-12-10 23:24

    You could do your headers like this just to make it a little easier to read and eliminate the concatenation:

    $headers = array(
        "Authorization:key=mykey",
        "Content-Type:application/json",
    );
    
    0 讨论(0)
提交回复
热议问题