我想在 php 代码中使用 REST 登录并验证用户数据。任何人都可以帮助我,我试图阅读 Bugzilla API 的文档,但我不明白如何应用它。我正在使用 codeigniter,这是我最后一次测试 url
function createIssue_get() {
$client_data = array(
'application_id' => 1,
'ios' => "IOS",
'type' => "dsfs",
'memory' => "32",
'storage' => "32",
'wifi' => "dsfd",
'carrier' => "erwre",
'battery_level' => "32423",
'battery_state' => "erwwer",
'country' => "ewre",
'city' => "ewrwre",
'console_log' => "drewrwer",
'duration' => "werwere",
'created_at' => date("Y-m-d H:i:s", now())
);
$username = 'xxxxxxx@gmail.com';
$password = 'xxxxxxxx';
$curl_handle = curl_init();
curl_setopt($curl_handle, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Accept: application/json"));
curl_setopt($curl_handle, CURLOPT_URL, 'https://api-dev.bugzilla.mozilla.org/test/latest/bug?username=xxxxx@gmail.com&password=xxxxxxx');
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl_handle, CURLOPT_POST, 1);
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, json_encode(array(
'product' => 'MyOwnBadSelf',
'summary' => substr('testing', 0, 20),
'version' => 'unspecified',
'component' => 'Comp1',
'op_sys' => "All",
'platform' => "Macintosh",
'priority' => "P5",
'severity' => "Trivial",
'whiteboard' => implode('', $this->array_map_assoc(function($k, $v) {
return "$k:\n$v\n\n";
}, $client_data))
)));
curl_setopt($curl_handle, CURLOPT_USERPWD, $username . ':' . $password);
$buffer = curl_exec($curl_handle);
curl_close($curl_handle);
echo $buffer;
}
它适用于创建错误,但我只需要验证用户名并通过???