daily pastebin goal
73%
SHARE
TWEET

Untitled

a guest Oct 23rd, 2017 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.         $username = 'username';
  3.         $password = 'password';
  4.         $curl = curl_init();
  5.         curl_setopt_array($curl, array(
  6.             CURLOPT_URL => "http://107.20.115.176:8080/rest/api/2/project",
  7.             CURLOPT_PORT => "8080",
  8.             CURLOPT_RETURNTRANSFER => true,
  9.             CURLOPT_ENCODING => "",
  10.             CURLOPT_MAXREDIRS => 10,
  11.             CURLOPT_TIMEOUT => 30,
  12.             CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  13.             CURLOPT_CUSTOMREQUEST => "GET",
  14.             CURLOPT_HTTPHEADER => array(
  15.                 "authorization: Basic ".base64_encode( $username . ":" . $password ),
  16.                 "cache-control: no-cache",
  17.                 "content-type: application/json"
  18.             ),
  19.         ));
  20.  
  21.         $response = curl_exec($curl);
  22.         $err = curl_error($curl);
  23.         curl_close($curl);
  24.         if ($err) {
  25.             echo "cURL Error #:" . $err;
  26.         } else {
  27.             //echo $response;
  28.             //var_dump($response);exit;
  29.             $projects = json_decode($response, true);
  30.             foreach ($projects as $project){
  31.                 $geturl = $project['self']; //Get url
  32.                 $getName = $project['name'];
  33.                 $curl = curl_init();
  34.                 curl_setopt_array($curl, array(
  35.                     CURLOPT_URL => $geturl,
  36.                     CURLOPT_PORT => "8080",
  37.                     CURLOPT_RETURNTRANSFER => true,
  38.                     CURLOPT_ENCODING => "",
  39.                     CURLOPT_MAXREDIRS => 10,
  40.                     CURLOPT_TIMEOUT => 30,
  41.                     CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  42.                     CURLOPT_CUSTOMREQUEST => "GET",
  43.                     CURLOPT_HTTPHEADER => array(
  44.                         "authorization: Basic ".base64_encode( $username . ":" . $password ),
  45.                         "cache-control: no-cache",
  46.                         "content-type: application/json"
  47.                     ),
  48.                 ));
  49.  
  50.                 $res = curl_exec($curl);
  51.                 $err = curl_error($curl);
  52.                 curl_close($curl);
  53.                 $details = json_decode($res, true);
  54.                 $getSex = $details['self'];
  55.                 //Gather all data
  56.                 $data = ['name' => $getName, 'sex' => $getSex];
  57.  
  58.             }
  59.             //var_dump($data);exit;
  60.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top