【发布时间】:2019-10-31 12:01:48
【问题描述】:
我正在为多个移动应用程序使用 web api。我将 PHP 用于我的 api。每个移动应用程序使用不同的 onesignal 帐户。在本机反应方面,我正在使用 axios 发送休息 API 密钥。在 api 方面,我想在 curl 中尝试这个 api 密钥。
我在 curl 中使用传统的点连接。但是当移动应用使用api时,它会返回空错误。
$api_key = 'ASDFGHJKLSI';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://onesignal.com/api/v1/notifications");
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json; charset=utf-8',
'Authorization: Basic ."$api_key".'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
在 curl 中使用变量是否正确?
【问题讨论】: