我想在PHP代码中使用REST登录并验证用户数据。 任何人都可以帮助我,我试图阅读Bugzilla API的文档但我无法理解如何应用它。 我正在使用codeigniter,这是我测试网址的最后一次试用
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;
}
它适用于创建bug但我需要验证用户名并通过???
答案 0 :(得分:0)
我不确定我是否理解你的问题,但是如果你试图将REST与CI一起使用,那么这是Phil Sturgeon制作的一个很酷的插件:
http://net.tutsplus.com/tutorials/php/working-with-restful-services-in-codeigniter-2/