我想使用网站的api向我的应用发送通知 并且网站帮助不好:/
网站说你应该在请求tokan代码和一些设置的标题中写 我如何用PHP发布json数据到这个网站? 用这些标题 “授权:令牌7fb1 .................................... 29b464c” “内容类型:application / json” “接受:application / json”
,网址来自网站的帮助文字 curl -X POST“https://panel.pushe.co/api/v1/notifications/”
请帮帮我@ _ @
答案 0 :(得分:1)
使用类似的东西:
$ curl -X POST -i -H "Content-Type: application/json" -H "Authorization: TOKEN <YOUR_TOKEN>" https://panel.pushe.co/api/v1/notifications/
答案 1 :(得分:0)
php示例
$data = array("name" => "Hagrid", "age" => "36");
$data_string = json_encode($data);
$ch = curl_init('http://api.local/rest/users');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$result = curl_exec($ch);