2013-04-09 72 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