您好我正在使用firebase和php并使用此library。
我收到此错误。"无法解析身份验证令牌。"
我的身份验证令牌是正确的,因为我也使用了与node.js相同的令牌。
我的代码看起来像这样
require "vendor/autoload.php";
const DEFAULT_URL = 'https://xxxxxxxxx.firebaseio.com';
const DEFAULT_TOKEN = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$firebase = new \Firebase\FirebaseLib(DEFAULT_URL, DEFAULT_TOKEN );
$data = [
"Website_Name"=> $Website_Name,
"Username" => $Username,
"Password"=> $Password,
"website_link"=> $website_link,
"id"=> $id,
];
$path = "per_users";
$res = $firebase->push('/per_users', $data);
// per_users is the name of the table
var_dump($res);
你可以告诉我我到底做错了什么。
感谢。
答案 0 :(得分:3)
我发现以下解决方案有效,如果有人仍想使用主题启动器this issue at GitHub:
frame.number frame.len frame.cap_len frame.Type
1 100 100 ICMP_tt
2 64 64 UDP
3 100 100 ICMP_tt
4 87 64 ICMP_nn
5 100 100 ICMP_tt
6 87 64 ICMP_nn
7 100 100 ICMP_tt
8 87 64 ICMP_nn
9 87 64 ICMP_nn
答案 1 :(得分:0)
我正在使用这样的思考,这对我有用。没有任何图书馆。简单。
// API access key from Google API's Console
define( 'API_ACCESS_KEY', 'YOUR_FIREBASE_API_KEY' ); //<--- here comes your api key from firebase
$registrationIds = array( "devices firebasetoken here." ); //<--- here comes device token (firebase generated token.)
// prep the bundle
$msg = array(
'body' => "message text",
'title' => "message title",
'vibrate' => 1,
'sound' => 1,
);
$fields = array(
'registration_ids' => $registrationIds,
'notification' => $msg
);
$headers = array(
'Authorization: key=' . API_ACCESS_KEY,
'Content-Type: application/json'
);
$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_RETURNTRANSFER, true );
curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) );
$result = curl_exec($ch );
curl_close( $ch );
echo $result;