예제 #1
0
	public function generate_link($link, $hash = "")
	{
		$response = remote::send_request($this->base_path . "shorts.json?apiKey=" . $this->key, array(
			"short[expanded]" => $link,
			"short[contracted]" => $hash
		));
		
		$response = json_decode($response);
		if($response->status_code == 200)
		{
			return $response->shorts->short->hashed; // Will return the hashed ID of the short.
		}
		else
		{
			throw new Exception($response->status_text, 500);
		}
	}