public function createBadge($data)
	{
		if (!$this->credentialsSet())
		{
			throw new Exception('You need to set the credentials first.');
		}

		$data['IssuerId'] = $this->credentials->issuerId;
		$data = json_encode($data);
		$accessToken = $this->credentials->access_token;
		$userAgent = $_SERVER['HTTP_USER_AGENT'];

		$headers = [
			'Cache-Control: no-cache',
			'Content-Type: application/json',
			"Authorization: Bearer $accessToken",
			"user-agent: $userAgent"
		];

		$request = curl_init();
		curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
		curl_setopt($request, CURLOPT_URL, 'https://www.openpassport.org/1.0.0/badges');
		curl_setopt($request, CURLOPT_POSTFIELDS, $data);
		curl_setopt($request, CURLOPT_POST, 1);
		curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($request, CURLOPT_VERBOSE, true);

		$response = curl_exec($request);
		$badge = json_decode($response);

		if (empty($badge->Id) || !$badge->Id)
		{
			throw new Exception($badge->message);
		}

		return $badge->Id;
	}
public function createBadge($data)
	{
		if (!$this->credentialsSet())
		{
			throw new Exception('You need to set the credentials first.');
		}

		$data['IssuerId'] = $this->credentials->issuerId;
		$data = json_encode($data);
		$accessToken = $this->credentials->access_token;
		$userAgent = $_SERVER['HTTP_USER_AGENT'];

		$headers = [
			'Cache-Control: no-cache',
			'Content-Type: application/json',
			"Authorization: Bearer $accessToken",
			"user-agent: $userAgent"
		];

		$request = curl_init();
		curl_setopt($request, CURLOPT_HTTPHEADER, $headers);
		curl_setopt($request, CURLOPT_URL, 'https://www.openpassport.org/1.0.0/badges');
		curl_setopt($request, CURLOPT_POSTFIELDS, $data);
		curl_setopt($request, CURLOPT_POST, 1);
		curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($request, CURLOPT_VERBOSE, true);

		$response = curl_exec($request);
		$badge = json_decode($response);

		if (empty($badge->Id) || !$badge->Id)
		{
			throw new Exception($badge->message);
		}

		return $badge->Id;
	}
public function createBadge ( $ data ) { if ( ! $ this -> credentialsSet ( ) ) { throw new Exception ( 'You need to set the credentials first.' ) ; } $ data [ 'IssuerId' ] = $ this -> credentials -> issuerId ; $ data = json_encode ( $ data ) ; $ accessToken = $ this -> credentials -> access_token ; $ userAgent = $ _SERVER [ 'HTTP_USER_AGENT' ] ; $ headers = [ 'Cache-Control: no-cache' , 'Content-Type: application/json' , "Authorization: Bearer $accessToken" , "user-agent: $userAgent" ] ; $ request = curl_init ( ) ; curl_setopt ( $ request , CURLOPT_HTTPHEADER , $ headers ) ; curl_setopt ( $ request , CURLOPT_URL , 'https://www.openpassport.org/1.0.0/badges' ) ; curl_setopt ( $ request , CURLOPT_POSTFIELDS , $ data ) ; curl_setopt ( $ request , CURLOPT_POST , 1 ) ; curl_setopt ( $ request , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ request , CURLOPT_VERBOSE , true ) ; $ response = curl_exec ( $ request ) ; $ badge = json_decode ( $ response ) ; if ( empty ( $ badge -> Id ) || ! $ badge -> Id ) { throw new Exception ( $ badge -> message ) ; } return $ badge -> Id ; }
Create a new badge

@param   array    $data  badge info. Must have the following:
$data['Name']          = 'Badge name';
$data['Description']   = 'Badge description';
$data['CriteriaUrl']   = 'Badge criteria URL';
$data['Version']       = 'Version';
$data['BadgeImageUrl'] = 'URL of the badge image: square at least 450px x 450px';
@return  integer  Freshly created badge ID
Create a new badge