Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $username = 'username';
- $password = 'password';
- $curl = curl_init();
- curl_setopt_array($curl, array(
- CURLOPT_URL => "http://107.20.115.176:8080/rest/api/2/project",
- CURLOPT_PORT => "8080",
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_ENCODING => "",
- CURLOPT_MAXREDIRS => 10,
- CURLOPT_TIMEOUT => 30,
- CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
- CURLOPT_CUSTOMREQUEST => "GET",
- CURLOPT_HTTPHEADER => array(
- "authorization: Basic ".base64_encode( $username . ":" . $password ),
- "cache-control: no-cache",
- "content-type: application/json"
- ),
- ));
- $response = curl_exec($curl);
- $err = curl_error($curl);
- curl_close($curl);
- if ($err) {
- echo "cURL Error #:" . $err;
- } else {
- //echo $response;
- //var_dump($response);exit;
- $projects = json_decode($response, true);
- foreach ($projects as $project){
- $geturl = $project['self']; //Get url
- $getName = $project['name'];
- $curl = curl_init();
- curl_setopt_array($curl, array(
- CURLOPT_URL => $geturl,
- CURLOPT_PORT => "8080",
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_ENCODING => "",
- CURLOPT_MAXREDIRS => 10,
- CURLOPT_TIMEOUT => 30,
- CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
- CURLOPT_CUSTOMREQUEST => "GET",
- CURLOPT_HTTPHEADER => array(
- "authorization: Basic ".base64_encode( $username . ":" . $password ),
- "cache-control: no-cache",
- "content-type: application/json"
- ),
- ));
- $res = curl_exec($curl);
- $err = curl_error($curl);
- curl_close($curl);
- $details = json_decode($res, true);
- $getSex = $details['self'];
- //Gather all data
- $data = ['name' => $getName, 'sex' => $getSex];
- }
- //var_dump($data);exit;
- }
Add Comment
Please, Sign In to add comment