Pergunta

I want to login and verify the user data using REST in php code. anyone can help me, I tried to read the Documentation of Bugzilla API but i could't understand how to apply it. I'm using codeigniter, and this was my last trial on testing 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;

}

it works for create bug but i need to just verify the username and pass ???

Foi útil?

Solução

Not sure if I understand your question right, but if you are trying to use REST with CI, this is a cool plugin made by Phil Sturgeon:

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top