2013-04-09 75 views
0

我想在php代码中使用REST登录并验证用户数据。 任何人都可以帮助我,我试着阅读Bugzilla API的文档,但我不知道如何应用它。 我使用笨,这是我的测试URL用PHP登录到Bugzilla使用PHP

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 = '[email protected]'; 
    $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/[email protected]&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; 

} 

它为创建错误庭审最后,但我只是需要验证用户名和通???

回答

0

不知道如果我理解你的问题的权利,但如果你要使用REST与CI,这是菲尔鲟鱼做了一个很酷的插件:

http://net.tutsplus.com/tutorials/php/working-with-restful-services-in-codeigniter-2/

+0

我的问题是,我需要报告在搜索后使用REST API的bugzilla的bug可以在Buzilla的测试服务器上使用,但使用bugzilla的实际应用程序......使用像https://landfill.bugzilla.org/bzapi_sandbox/enter_bug.cgi这样的CGI工具,我需要知道如何处理 – 2013-04-11 10:06:28