<?php 

 		$subject ="this is test frpom curl ";

			//extract data from the post
			//set POST variables
			$email_order ='This is a test ticket. Please Ignore.';
			$url = 'https://livingsupplements.atlassian.net/rest/api/2/issue/';
			$fields = array('fields'=>array(
							'project' => array('key'=>'LS'),
							'summary' => "Order Confirmation No: Test Please Ignore",
							'description' => "This is a test ticket. Please Ignore.",
							"issuetype" => array(
								"id"=>"10011"
							),
							"reporter" => array(
							"accountId"=>"qm:45ff4e8b-5dff-4a77-b5b3-f15eb65d2ceb:a3947ccc-db5a-4a83-aee6-e048e9b0c221",
							"emailAddress"=>"testuser1@gmail.com" ,
							"displayName" =>"test user 1"
							),
						)		
					);
			
			//url-ify the data for the POST
			/*foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
			rtrim($fields_string, '&');
			*/
			 $fields_string = json_encode($fields);
			echo $fields_string;
			$user ='dean@livingnetwork.co.za';
			$password = 'VfYFbQ1FKidd3PbV6v6y6DCD';
			
			$user_pass="{$user}:$password";

			$authorization=base64_encode($user_pass);

			$headers=array('Content-Type: application/json',
							'Accept: application/json',
							'Authorization: Basic '.$authorization);
							
			//open connection
			$ch = curl_init();
			
			//set the url, number of POST vars, POST data
			curl_setopt($ch,CURLOPT_URL, $url);
			//curl_setopt($ch,CURLOPT_POST, count($fields));
			curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
			curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
			
			//execute post
			$result = curl_exec($ch);
			
			//close connection
			curl_close($ch);
			echo $result;
?>