0
我試圖構建一個使用simplenote api的應用程序,但我在身份驗證部分遇到問題。我收到一個400錯誤(錯誤的請求)。 我猜這個問題與simplenote api無關,而是我對文檔的理解。通過郵件從api中檢索身份驗證令牌
下面是該API是說:
HTTP POST到以下網址: https://simple-note.appspot.com/api/login
請求的主體應該包含這一點,但base64編碼: 電子郵件=電子郵件-address] &密碼= [密碼]
要清楚,你會串連電子郵件=用戶的電子郵件地址(修剪), &通word =,和用戶的密碼;然後base64得到的字符串並將其作爲 發送給HTTP請求主體。 (不編碼使用用於張貼Web表單標準變量 編碼申請。我們基本上忽略了內容+ Type頭 此請求,但純文本/這裏是最有意義的。)
這裏是我到目前爲止的代碼:
$url = 'https://simple-note.appspot.com/api/login';
$data = array('email' => base64_encode($email), 'password' => base64_encode($password));
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data),
),
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
var_dump($result);
謝謝!將嘗試捲曲! – Inzajt