curl - Login using php -
i have tried following code login authentication not working.
<?php define('url', 'https://xxxxxxxxxxxx.com'); function authenticate($uname, $pass) { $url = url . 'issue/bug-5555'; $curl = curl_init(); curl_setopt($curl, curlopt_userpwd, "$uname:$pass"); curl_setopt($curl, curlopt_url, $url); curl_setopt($curl, curlopt_returntransfer, 1); curl_setopt($curl, curlopt_followlocation, 1); curl_setopt($curl, curlopt_ssl_verifypeer, 0); // ssl ensure cert curl_setopt($curl, curlopt_ssl_verifyhost, 1); /// ssl ensure cert $issue_list = (curl_exec($curl)); echo $issue_list; return $issue_list; } ?>
you didn't mention trying achieve code. trying ticket info, post issue? using api...
well here's script works jira api.
<?php $username = 'test'; $password = 'test'; $url = "https://xxxxx.xxxxxxx.net/rest/api/2/project"; $ch = curl_init(); $headers = array( 'accept: application/json', 'content-type: application/json' ); $test = "this content of custom field."; curl_setopt($ch, curlopt_returntransfer, true); curl_setopt($ch, curlopt_verbose, 1); curl_setopt($ch, curlopt_ssl_verifypeer, 0); curl_setopt($ch, curlopt_ssl_verifyhost, 0); curl_setopt($ch, curlopt_httpheader, $headers); curl_setopt($ch, curlopt_customrequest, "get"); //curl_setopt($ch, curlopt_postfields, $data); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_userpwd, "$username:$password"); $result = curl_exec($ch); $ch_error = curl_error($ch); if ($ch_error) { echo "curl error: $ch_error"; } else { echo $result; } curl_close($ch); ?>
this code fetching project jira. if want create issues, have change rest url /rest/api/2/issue/ , use "post" instead of "get" method.
Comments
Post a Comment