Last active
October 30, 2015 10:56
-
-
Save YOzaz/dff89d18780307965ea3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* ... */ | |
const RETURN_FORMAT_JSON = 'json'; | |
const RETURN_FORMAT_XML = 'xml'; | |
/** | |
* Generates new short URL | |
* | |
* @param string $url | |
* @param string $format | |
* | |
* @return string|null | |
*/ | |
public function createShortUrl( $url = '', $format = null ) | |
{ | |
$data = [ | |
'signature' => $this->token, | |
'format' => $format ?: self::RETURN_FORMAT_JSON, | |
'action' => 'shorturl', | |
'url' => $url | |
]; | |
$result = $this->library->post( '/', $data ); | |
if ( isset($result) && isset($result->shorturl) ) | |
{ | |
return $result->shorturl; | |
} | |
else | |
{ | |
return null; | |
} | |
} | |
/* ... */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment