├── .gitignore ├── .gitattributes ├── .travis.yml ├── src ├── Jelovac │ └── Bitly4laravel │ │ ├── Facades │ │ └── Bitly4laravel.php │ │ ├── Exceptions │ │ ├── NonBooleanTypeException.php │ │ ├── NonIntegerTypeException.php │ │ ├── NonStringTypeException.php │ │ └── InvalidTypeException.php │ │ ├── Laravel4ServiceProvider.php │ │ ├── Laravel5ServiceProvider.php │ │ ├── Bitly4laravelServiceProvider.php │ │ ├── API.php │ │ ├── BitlyInterface.php │ │ ├── Model.php │ │ └── Bitly4laravel.php └── config │ └── config.php ├── composer.json ├── CONTRIBUTING.md ├── phpunit.xml ├── tests └── ModelTest.php └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | /nbproject 2 | /vendor 3 | composer.phar 4 | composer.lock 5 | .DS_Store -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Set default behaviour, in case users don't have core.autocrlf set. 2 | * text=auto -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | 3 | php: 4 | - 5.4 5 | - 5.5 6 | 7 | before_script: 8 | - curl -s http://getcomposer.org/installer | php 9 | - php composer.phar install --dev 10 | 11 | script: phpunit -------------------------------------------------------------------------------- /src/Jelovac/Bitly4laravel/Facades/Bitly4laravel.php: -------------------------------------------------------------------------------- 1 | null, 8 | "cache_enabled" => false, 9 | "cache_duration" => 3600, // Duration in minutes 10 | "cache_key_prefix" => "Bitly4Laravel.", 11 | "response_format" => "json", // json, xml 12 | "request_type" => "get", // get, post 13 | "request_options" => array(), 14 | "client_config" => array(), 15 | ); 16 | -------------------------------------------------------------------------------- /src/Jelovac/Bitly4laravel/Exceptions/NonBooleanTypeException.php: -------------------------------------------------------------------------------- 1 | assembleMessage($var, 'Boolean'); 16 | parent::__construct($message); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/Jelovac/Bitly4laravel/Exceptions/NonIntegerTypeException.php: -------------------------------------------------------------------------------- 1 | assembleMessage($var, 'Integer'); 16 | parent::__construct($message); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/Jelovac/Bitly4laravel/Exceptions/NonStringTypeException.php: -------------------------------------------------------------------------------- 1 | assembleMessage($var, 'String'); 16 | parent::__construct($message); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jelovac/bitly4laravel", 3 | "description": "Provides a Laravel package to communicate with Bit.ly API", 4 | "license": "MIT", 5 | "require": { 6 | "php": ">=5.4", 7 | "illuminate/support": "~4|~5", 8 | "guzzlehttp/guzzle": "~5" 9 | }, 10 | "require-dev": { 11 | "phpunit/phpunit": "4.4.*" 12 | }, 13 | "autoload": { 14 | "psr-0": { 15 | "Jelovac\\Bitly4laravel\\": "src/" 16 | } 17 | }, 18 | "minimum-stability": "dev" 19 | } 20 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to bitly4laravel repository 2 | 3 | Thank you for willing to contribute to this project. Before doing so, please, read the following guidelines. 4 | 5 | ## Submitting the issues 6 | 7 | When submitting new issues please consider the following: 8 | 9 | * Prior to creating a new issue check if an issue has already been reported (use search) 10 | * When submitting a new issue specify: 11 | * Laravel version (Example: 4.2.0) 12 | * bitly4laravel version (Example: 3.1.0) 13 | * if the issue can be related to caching and caching is enabled please mention it in the description -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 15 | ./tests/ 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/Jelovac/Bitly4laravel/Exceptions/InvalidTypeException.php: -------------------------------------------------------------------------------- 1 | package('jelovac/bitly4laravel'); 16 | } 17 | 18 | /** 19 | * Register the service provider. 20 | * 21 | * @return void 22 | */ 23 | public function register() 24 | { 25 | $this->app['bitly4laravel'] = $this->app->share(function($app) { 26 | $config = $app['config']->get('bitly4laravel::config'); 27 | return new Bitly4laravel($config); 28 | }); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/Jelovac/Bitly4laravel/Laravel5ServiceProvider.php: -------------------------------------------------------------------------------- 1 | config_path("bitly4laravel.php"), 19 | ); 20 | 21 | $this->publishes($paths, 'config'); 22 | } 23 | 24 | /** 25 | * Register the service provider. 26 | * 27 | * @return void 28 | */ 29 | public function register() 30 | { 31 | $this->app['bitly4laravel'] = $this->app->share(function($app) { 32 | $config = $app['config']->get('bitly4laravel'); 33 | return new Bitly4laravel($config); 34 | }); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /tests/ModelTest.php: -------------------------------------------------------------------------------- 1 | model = new Model; 16 | } 17 | 18 | /** 19 | * @expectedException \InvalidArgumentException 20 | */ 21 | public function testSetConfigThrowsInvalidArgumentException() 22 | { 23 | $this->model->setConfig(array( 24 | 'invalid_key' => 1, 25 | )); 26 | } 27 | 28 | public function testSetAccessTokenSuccess() 29 | { 30 | $this->model->setAccessToken("1"); 31 | $this->assertEquals("1", $this->model->getAccessToken()); 32 | } 33 | 34 | /** 35 | * @expectedException \Jelovac\Bitly4laravel\Exceptions\NonStringTypeException 36 | */ 37 | public function testSetAccessTokenThrowsNonStringTypeException() 38 | { 39 | $this->model->setAccessToken(1); 40 | } 41 | 42 | public function testGetRequestParamSuccess() 43 | { 44 | $requestParam = "https://github.com/jelovac/bitly4laravel"; 45 | $this->model->setRequestParam('longUrl', $requestParam); 46 | $this->assertEquals($requestParam, $this->model->getRequestParam('longUrl')); 47 | } 48 | 49 | /** 50 | * @expectedException \OutOfRangeException 51 | */ 52 | public function testGetRequestParamThrowsOutOfRangeException() 53 | { 54 | $model = new Model; 55 | $model->getRequestParam('longUrl'); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/Jelovac/Bitly4laravel/Bitly4laravelServiceProvider.php: -------------------------------------------------------------------------------- 1 | provider = $this->getProvider(); 32 | } 33 | 34 | /** 35 | * Bootstrap the application events. 36 | * 37 | * @return void 38 | */ 39 | public function boot() 40 | { 41 | return $this->provider->boot(); 42 | } 43 | 44 | /** 45 | * Register the service provider. 46 | * 47 | * @return void 48 | */ 49 | public function register() 50 | { 51 | return $this->provider->register(); 52 | } 53 | 54 | /** 55 | * Return ServiceProvider according to Laravel version 56 | * 57 | * @return \Intervention\Image\Provider\ProviderInterface 58 | */ 59 | private function getProvider() 60 | { 61 | $app = $this->app; 62 | $version = intval($app::VERSION); 63 | $provider = sprintf('\Jelovac\Bitly4laravel\Laravel%dServiceProvider', $version); 64 | return new $provider($app); 65 | } 66 | 67 | /** 68 | * Get the services provided by the provider. 69 | * 70 | * @return array 71 | */ 72 | public function provides() 73 | { 74 | return array('bitly4laravel'); 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | bitly4laravel 2 | ============= 3 | [![Build Status](https://travis-ci.org/jelovac/bitly4laravel.png?branch=master)](https://travis-ci.org/jelovac/bitly4laravel) [![Latest Stable Version](https://poser.pugx.org/jelovac/bitly4laravel/v/stable.png)](https://packagist.org/packages/jelovac/bitly4laravel) [![Total Downloads](https://poser.pugx.org/jelovac/bitly4laravel/downloads.png)](https://packagist.org/packages/jelovac/bitly4laravel) [![Latest Unstable Version](https://poser.pugx.org/jelovac/bitly4laravel/v/unstable.png)](https://packagist.org/packages/jelovac/bitly4laravel) [![License](https://poser.pugx.org/jelovac/bitly4laravel/license.png)](https://packagist.org/packages/jelovac/bitly4laravel) 4 | 5 | Provides a Laravel package to communicate with Bit.ly API. 6 | 7 | In order to use this package you need to get [OAuth Generic Access Token](https://bitly.com/a/oauth_apps) from Bitly website. 8 | 9 | Instalation 10 | =========== 11 | 12 | Warning this is v3 version of bitly4laravel package. If you want to use the old v2 version use the v2 branch. 13 | 14 | Add bitly4laravel to your composer.json file. 15 | 16 | require : { 17 | "jelovac/bitly4laravel": "3.*" 18 | } 19 | 20 | Or with composer command: 21 | 22 | composer require "jelovac/bitly4laravel": "3.*" 23 | 24 | Add provider to your app/config/app.php providers 25 | 26 | 'Jelovac\Bitly4laravel\Bitly4laravelServiceProvider', 27 | 28 | Publish config 29 | 30 | For Laravel 5 use: 31 | 32 | php artisan vendor:publish 33 | 34 | For Laravel 4 use: 35 | 36 | php artisan config:publish jelovac/bitly4laravel 37 | 38 | Optional (recommended) 39 | ====================== 40 | 41 | Add alias to app/config/app.php aliases 42 | 43 | 'Bitly' => 'Jelovac\Bitly4laravel\Facades\Bitly4laravel', 44 | 45 | Usage 46 | ===== 47 | 48 | Shorten links 49 | 50 | Bitly::shorten('http://google.com/'); 51 | 52 | Response format: JSON 53 | 54 | { 55 | "data": { 56 | "global_hash": "900913", 57 | "hash": "ze6poY", 58 | "long_url": "http://google.com/", 59 | "new_hash": 0, 60 | "url": "http://bit.ly/ze6poY" 61 | }, 62 | "status_code": 200, 63 | "status_txt": "OK" 64 | } 65 | 66 | Expand links 67 | 68 | Bitly::expand('http://bit.ly/ze6poY'); 69 | 70 | Response format: JSON 71 | 72 | { 73 | "data": { 74 | "expand": [ 75 | { 76 | "global_hash": "900913", 77 | "long_url": "http://google.com/", 78 | "short_url": "http://bit.ly/ze6poY", 79 | "user_hash": "ze6poY" 80 | } 81 | ] 82 | }, 83 | "status_code": 200, 84 | "status_txt": "OK" 85 | } 86 | 87 | Repository 88 | ========== 89 | https://github.com/jelovac/bitly4laravel 90 | 91 | License 92 | ======= 93 | 94 | The Bitly4laravel package is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT) 95 | -------------------------------------------------------------------------------- /src/Jelovac/Bitly4laravel/API.php: -------------------------------------------------------------------------------- 1 | requestParams['access_token'] = $this->accessToken; 18 | $this->requestParams['format'] = $this->responseFormat; 19 | 20 | if (!empty($params)) { 21 | $this->requestParams = array_merge($this->requestParams , $params); 22 | } 23 | 24 | if ($this->cacheEnabled) { 25 | 26 | $cacheKey = $this->createCacheKey($action); 27 | 28 | // Check if the value is already cached 29 | if (Cache::has($cacheKey)) { 30 | return Cache::get($cacheKey); 31 | } 32 | } 33 | 34 | $response = $this->call($action, $this->requestParams); 35 | 36 | if ($this->cacheEnabled) { 37 | Cache::put($cacheKey, $response, $this->cacheDuration); 38 | } 39 | 40 | return $response; 41 | } 42 | 43 | /** 44 | * Execute the request and return the response 45 | * 46 | * @param string $action 47 | * @param array $params 48 | * @return mixed 49 | */ 50 | protected function call($action, array $params = array()) 51 | { 52 | $url = static::API_URL . '/' . static::API_VERSION . '/' . $action; 53 | 54 | $client = new Client($this->clientConfig); 55 | 56 | try { 57 | 58 | $options = array_merge(array('query' => $params), $this->requestOptions); 59 | 60 | switch (strtolower($this->requestType)) { 61 | 62 | case 'post': 63 | 64 | $response = $client->post($url, $options); 65 | 66 | break; 67 | 68 | case 'get': 69 | 70 | default: 71 | $response = $client->get($url, $options); 72 | } 73 | 74 | switch (strtolower($this->responseFormat)) { 75 | 76 | case 'xml': 77 | 78 | $body = $response->xml(); 79 | 80 | break; 81 | 82 | case 'json': 83 | 84 | default: 85 | $body = $response->json(); 86 | } 87 | 88 | return $body; 89 | } catch (BadResponseException $ex) { 90 | return $ex->getResponse()->getBody(); 91 | } 92 | } 93 | 94 | /** 95 | * Create cache key 96 | * 97 | * @param string $action 98 | * @return type 99 | */ 100 | protected function createCacheKey($action) 101 | { 102 | $key = $this->cacheKeyPrefix . $action . json_encode($this->requestParams); 103 | return sha1($key); 104 | } 105 | 106 | } 107 | -------------------------------------------------------------------------------- /src/Jelovac/Bitly4laravel/BitlyInterface.php: -------------------------------------------------------------------------------- 1 | setConfig($config); 92 | } 93 | } 94 | 95 | /** 96 | * Set configuration 97 | * 98 | * @param array $config 99 | * @return \Jelovac\Bitly4laravel\Model 100 | * @throws InvalidArgumentException 101 | */ 102 | public function setConfig(array $config) 103 | { 104 | foreach ($config as $key => $value) { 105 | if (is_string($key)) { 106 | $key = "set_" . $key; 107 | $name = $this->snakeCaseToCamelCase($key); 108 | $this->callSetter($name, $value); 109 | } else { 110 | throw new InvalidArgumentException("Invalid config key set!"); 111 | } 112 | } 113 | 114 | return $this; 115 | } 116 | 117 | /** 118 | * Call the setter method 119 | * 120 | * @param type $name 121 | * @param type $value 122 | * @throws InvalidArgumentException 123 | */ 124 | protected function callSetter($name, $value) 125 | { 126 | if (method_exists(__CLASS__, $name)) { 127 | $this->{$name}($value); 128 | } else { 129 | throw new InvalidArgumentException("Invalid config key set!"); 130 | } 131 | } 132 | 133 | /** 134 | * Converts snake_case to camelCase 135 | * 136 | * @param type $value 137 | * @return string 138 | * @throws NonStringTypeException 139 | */ 140 | protected function snakeCaseToCamelCase($value) 141 | { 142 | if (is_string($value)) { 143 | $value = str_replace(' ', '', ucwords(str_replace('_', ' ', $value))); 144 | $value = strtolower(substr($value, 0, 1)) . substr($value, 1); 145 | return $value; 146 | } else { 147 | throw new NonStringTypeException($value); 148 | } 149 | } 150 | 151 | /** 152 | * Get Bitly OAuth Generic Access Token 153 | * 154 | * @return string 155 | */ 156 | public function getAccessToken() 157 | { 158 | return $this->accessToken; 159 | } 160 | 161 | /** 162 | * Set Bitly OAuth Generic Access Token 163 | * 164 | * @param type $accessToken 165 | * @return \Jelovac\Bitly4laravel\Model 166 | * @throws NonStringTypeException 167 | */ 168 | public function setAccessToken($accessToken) 169 | { 170 | if (is_string($accessToken)) { 171 | $this->accessToken = $accessToken; 172 | return $this; 173 | } else { 174 | throw new NonStringTypeException($accessToken); 175 | } 176 | } 177 | 178 | /** 179 | * Get cache enabled 180 | * 181 | * @return bool 182 | */ 183 | public function getCacheEnabled() 184 | { 185 | return $this->cacheEnabled; 186 | } 187 | 188 | /** 189 | * Set cache enabled 190 | * 191 | * @param bool $cacheEnabled 192 | * @return \Jelovac\Bitly4laravel\Model 193 | * @throws NonBooleanTypeException 194 | */ 195 | public function setCacheEnabled($cacheEnabled) 196 | { 197 | if (is_bool($cacheEnabled)) { 198 | $this->cacheEnabled = $cacheEnabled; 199 | return $this; 200 | } else { 201 | throw new NonBooleanTypeException($cacheEnabled); 202 | } 203 | } 204 | 205 | /** 206 | * Get cache duration in minutes 207 | * 208 | * @return int 209 | */ 210 | public function getCacheDuration() 211 | { 212 | return $this->cacheDuration; 213 | } 214 | 215 | /** 216 | * Set cache duration in minutes 217 | * 218 | * @param type $cacheDuration 219 | * @return \Jelovac\Bitly4laravel\Model 220 | * @throws NonIntegerTypeException 221 | */ 222 | public function setCacheDuration($cacheDuration) 223 | { 224 | if (is_int($cacheDuration)) { 225 | $this->cacheDuration = $cacheDuration; 226 | return $this; 227 | } else { 228 | throw new NonIntegerTypeException($cacheDuration); 229 | } 230 | } 231 | 232 | /** 233 | * Get cache key prefix 234 | * 235 | * @return string 236 | */ 237 | public function getCacheKeyPrefix() 238 | { 239 | return $this->cacheKeyPrefix; 240 | } 241 | 242 | /** 243 | * Set cache key prefix 244 | * 245 | * @param type $cacheKeyPrefix 246 | * @return \Jelovac\Bitly4laravel\Model 247 | * @throws NonStringTypeException 248 | */ 249 | public function setCacheKeyPrefix($cacheKeyPrefix) 250 | { 251 | if (is_string($cacheKeyPrefix)) { 252 | $this->cacheKeyPrefix = $cacheKeyPrefix; 253 | return $this; 254 | } else { 255 | throw new NonStringTypeException($cacheKeyPrefix); 256 | } 257 | } 258 | 259 | /** 260 | * Get GuzzleHttp Client configuration 261 | * 262 | * @return array 263 | */ 264 | public function getClientConfig() 265 | { 266 | return $this->clientConfig; 267 | } 268 | 269 | /** 270 | * Set GuzzleHttp Client configuration 271 | * 272 | * @param array $clientConfig 273 | * @return \Jelovac\Bitly4laravel\Model 274 | */ 275 | public function setClientConfig(array $clientConfig) 276 | { 277 | $this->clientConfig = $clientConfig; 278 | return $this; 279 | } 280 | 281 | /** 282 | * Get Bitly API response format 283 | * 284 | * @return string 285 | */ 286 | public function getResponseFormat() 287 | { 288 | return $this->responseFormat; 289 | } 290 | 291 | /** 292 | * Set Bitly API response format 293 | * 294 | * @param string $responseFormat 295 | * @return \Jelovac\Bitly4laravel\Model 296 | * @throws NonStringTypeException 297 | */ 298 | public function setResponseFormat($responseFormat) 299 | { 300 | if (is_string($responseFormat)) { 301 | $this->responseFormat = $responseFormat; 302 | return $this; 303 | } else { 304 | throw new NonStringTypeException($responseFormat); 305 | } 306 | } 307 | 308 | /** 309 | * Get GuzzleHttp Client request options 310 | * 311 | * @return array 312 | */ 313 | public function getRequestOptions() 314 | { 315 | return $this->requestOptions; 316 | } 317 | 318 | /** 319 | * Set GuzzleHttp Client request options 320 | * 321 | * @param array $requestOptions 322 | * @return \Jelovac\Bitly4laravel\Model 323 | */ 324 | public function setRequestOptions(array $requestOptions) 325 | { 326 | $this->requestOptions = $requestOptions; 327 | return $this; 328 | } 329 | 330 | /** 331 | * Get request param 332 | * 333 | * @param mixed $key 334 | * @return mixed 335 | * @throws OutOfRangeException 336 | */ 337 | public function getRequestParam($key) 338 | { 339 | if (array_key_exists($key, $this->requestParams)) { 340 | return $this->requestParams[$key]; 341 | } else { 342 | throw new OutOfRangeException("Provided array key is out of range."); 343 | } 344 | } 345 | 346 | /** 347 | * Set request param 348 | * 349 | * @param type $key 350 | * @param type $value 351 | * @return \Jelovac\Bitly4laravel\Model 352 | */ 353 | public function setRequestParam($key, $value) 354 | { 355 | $this->requestParams[$key] = $value; 356 | return $this; 357 | } 358 | 359 | /** 360 | * Get request params 361 | * 362 | * @return array 363 | */ 364 | public function getRequestParams() 365 | { 366 | return $this->requestParams; 367 | } 368 | 369 | /** 370 | * Set request params 371 | * 372 | * @param array $requestParams 373 | * @return \Jelovac\Bitly4laravel\Model 374 | */ 375 | public function setRequestParams(array $requestParams) 376 | { 377 | $this->requestParams = $requestParams; 378 | return $this; 379 | } 380 | 381 | /** 382 | * Get GuzzleHttp Client request type 383 | * 384 | * @return string 385 | */ 386 | public function getRequestType() 387 | { 388 | return $this->requestType; 389 | } 390 | 391 | /** 392 | * Set GuzzleHttp Client request type 393 | * 394 | * @param string $requestType 395 | * @return \Jelovac\Bitly4laravel\Model 396 | * @throws NonStringTypeException 397 | */ 398 | public function setRequestType($requestType) 399 | { 400 | if (is_string($requestType)) { 401 | $this->requestType = $requestType; 402 | return $this; 403 | } else { 404 | throw new NonStringTypeException($requestType); 405 | } 406 | } 407 | 408 | } 409 | -------------------------------------------------------------------------------- /src/Jelovac/Bitly4laravel/Bitly4laravel.php: -------------------------------------------------------------------------------- 1 | make('bundle/archive', array( 14 | 'bundle_link' => $budleLink 15 | )); 16 | } 17 | 18 | /** 19 | * Returns a list of public bundles created by a user. 20 | * 21 | * @param string $user 22 | * @param boolean $expandUser 23 | * @return type 24 | */ 25 | public function bundleBundlesByUser($user, $expandUser = null) 26 | { 27 | $params = array('user' => $user); 28 | 29 | if ($expandUser !== null) { 30 | $params['expand_user'] = $expandUser; 31 | } 32 | 33 | return $this->make('bundle/bundles_by_user', $params); 34 | } 35 | 36 | /** 37 | * Clone a bundle for the authenticated user. 38 | * 39 | * @param string $budleLink 40 | * @return type 41 | */ 42 | public function bundleClone($budleLink) 43 | { 44 | return $this->make('bundle/clone', array('bundle_link', $budleLink)); 45 | } 46 | 47 | /** 48 | * Add a collaborator to a bundle. 49 | * 50 | * @param string $budleLink 51 | * @param string $collaborator 52 | * @return type 53 | */ 54 | public function bundleCollaboratorAdd($budleLink, $collaborator) 55 | { 56 | return $this->make('bundle/collaborator_add', array( 57 | 'bundle_link' => $budleLink, 58 | 'collaborator' => $collaborator, 59 | )); 60 | } 61 | 62 | /** 63 | * Remove a collaborator from a bundle. 64 | * 65 | * @param string $budleLink 66 | * @param string $collaborator 67 | * @return type 68 | */ 69 | public function bundleCollaboratorRemove($budleLink, $collaborator) 70 | { 71 | return $this->make('bundle/collaborator_remove', array( 72 | 'bundle_link' => $budleLink, 73 | 'collaborator' => $collaborator 74 | )); 75 | } 76 | 77 | /** 78 | * Returns information about a bundle. 79 | * 80 | * @param string $bundleLink 81 | * @param boolean $expandUser 82 | * @return type 83 | */ 84 | public function bundleContents($bundleLink, $expandUser = null) 85 | { 86 | $params = array('bundle_link' => $bundleLink); 87 | 88 | if ($expandUser !== null) { 89 | $params['expand_user'] = $expandUser; 90 | } 91 | 92 | return $this->make('bundle/contents', $params); 93 | } 94 | 95 | /** 96 | * Create a new bundle for the authenticated user. 97 | * 98 | * @param boolean $private 99 | * @param string $title 100 | * @param string $description 101 | * @return type 102 | */ 103 | public function bundleCreate($private = null, $title = null, $description = null) 104 | { 105 | $params = array(); 106 | 107 | if ($private !== null) { 108 | $params['private'] = $private; 109 | } 110 | 111 | if ($title !== null) { 112 | $params['title'] = $title; 113 | } 114 | 115 | if ($description !== null) { 116 | $params['description'] = $description; 117 | } 118 | 119 | return $this->make('bundle/create', $params); 120 | } 121 | 122 | /** 123 | * Edit a bundle for the authenticated user 124 | * 125 | * @param string $bundleLink 126 | * @param string $edit 127 | * @param string $title 128 | * @param string $description 129 | * @param boolean $private 130 | * @param boolean $preview 131 | * @param string $ogImage 132 | * @return type 133 | */ 134 | public function bundleEdit($bundleLink, $edit = null, $title = null, $description = null, $private = null, $preview = null, $ogImage = null) 135 | { 136 | $params = array('bundle_link' => $bundleLink); 137 | 138 | if ($edit !== null) { 139 | $params['edit'] = $edit; 140 | } 141 | 142 | if ($title !== null) { 143 | $params['title'] = $title; 144 | } 145 | 146 | if ($description !== null) { 147 | $params['description'] = $description; 148 | } 149 | 150 | if ($private !== null) { 151 | $params['private'] = $private; 152 | } 153 | 154 | if ($preview !== null) { 155 | $params['preview'] = $preview; 156 | } 157 | 158 | if ($ogImage !== null) { 159 | $params['og_image'] = $ogImage; 160 | } 161 | 162 | return $this->make('bundle/edit', $params); 163 | } 164 | 165 | /** 166 | * Returns all bundles this user has access to (public + private + collaborator). 167 | * 168 | * @param boolean $expandUser 169 | * @return type 170 | */ 171 | public function userBundleHistory($expandUser = null) 172 | { 173 | $params = array(); 174 | 175 | if ($expandUser !== null) { 176 | $params['expand_user'] = $expandUser; 177 | } 178 | 179 | return $this->make('user/bundle_history', $params); 180 | } 181 | 182 | /** 183 | * Adds a link to a bitly bundle. Links are automatically added to the top (position 0) of a bundle. 184 | * 185 | * @param string $bundleLink 186 | * @param string $link 187 | * @param string $title 188 | * @return type 189 | */ 190 | public function bundleLinkAdd($bundleLink, $link, $title = null) 191 | { 192 | $params = array( 193 | 'bundle_link' => $bundleLink, 194 | 'link' => $link, 195 | ); 196 | 197 | if ($title !== null) { 198 | $params['title'] = $title; 199 | } 200 | 201 | return $this->make('bundle/link_add', $params); 202 | } 203 | 204 | /** 205 | * Add a comment to bundle item. 206 | * 207 | * @param string $bundleLink 208 | * @param string $link 209 | * @param string $comment 210 | * @return type 211 | */ 212 | public function bundleLinkCommentAdd($bundleLink, $link, $comment) 213 | { 214 | return $this->make('bundle/link_comment_add', array( 215 | 'bundle_link' => $bundleLink, 216 | 'link' => $link, 217 | 'comment' => $comment, 218 | )); 219 | } 220 | 221 | /** 222 | * Add a comment to bundle item. 223 | * 224 | * @param string $bundleLink 225 | * @param string $link 226 | * @param integer $commentId 227 | * @param string $comment 228 | * @return type 229 | */ 230 | public function bundleLinkCommentEdit($bundleLink, $link, $commentId, $comment) 231 | { 232 | return $this->make('bundle/link_comment_edit', array( 233 | 'bundle_link' => $bundleLink, 234 | 'link' => $link, 235 | 'comment_id' => $commentId, 236 | 'comment' => $comment, 237 | )); 238 | } 239 | 240 | /** 241 | * Remove a comment from a bundle item. Only the original commenter and the bundles owner may perform this action. 242 | * 243 | * @param string $bundleLink 244 | * @param string $link 245 | * @param integer $commentId 246 | * @return type 247 | */ 248 | public function bundleLinkCommentRemove($bundleLink, $link, $commentId) 249 | { 250 | return $this->make('bundle/link_comment_remove', array( 251 | 'bundle_link' => $bundleLink, 252 | 'link' => $link, 253 | 'comment_id' => $commentId, 254 | )); 255 | } 256 | 257 | /** 258 | * Edit the title for a link. 259 | * 260 | * @param string $bundleLink 261 | * @param string $link 262 | * @param string $edit 263 | * @param string $title 264 | * @param boolean $preview 265 | * @return type 266 | */ 267 | public function bundleLinkEdit($bundleLink, $link, $edit, $title = null, $preview = null) 268 | { 269 | $params = array( 270 | 'bundle_link' => $bundleLink, 271 | 'link' => $link, 272 | 'edit' => $edit, 273 | ); 274 | 275 | if ($title !== null) { 276 | $params['title'] = $title; 277 | } 278 | 279 | if ($preview !== null) { 280 | $params['preview'] = $preview; 281 | } 282 | 283 | return $this->make('bundle/link_edit', $params); 284 | } 285 | 286 | /** 287 | * Remove a link from a bitly bundle 288 | * 289 | * @param string $bundleLink 290 | * @param string $link 291 | * @return type 292 | */ 293 | public function bundleLinkRemove($bundleLink, $link) 294 | { 295 | return $this->make('bundle/link_remove', array( 296 | 'bundle_link' => $bundleLink, 297 | 'link' => $link, 298 | )); 299 | } 300 | 301 | /** 302 | * Change the position of a link in a bitly bundle. 303 | * 304 | * @param string $bundleLink 305 | * @param string $link 306 | * @param integer $displayOrder 307 | * @return type 308 | */ 309 | public function bundleLinkReorder($bundleLink, $link, $displayOrder) 310 | { 311 | return $this->make('bundle/link_reorder', array( 312 | 'bundle_link' => $bundleLink, 313 | 'link' => $link, 314 | 'display_order' => $displayOrder, 315 | )); 316 | } 317 | 318 | /** 319 | * Removes a pending/invited collaborator from a bundle. 320 | * 321 | * @param string $bundleLink 322 | * @param string $collaborator 323 | * @return type 324 | */ 325 | public function bundlePendingCollaboratorRemove($bundleLink, $collaborator) 326 | { 327 | return $this->make('bundle/pending_collaborator_remove', array( 328 | 'bundle_link' => $bundleLink, 329 | 'collaborator' => $collaborator, 330 | )); 331 | } 332 | 333 | /** 334 | * Re-order the links in a bundle. 335 | * 336 | * @param string $bundleLink 337 | * @param string $link 338 | * @return type 339 | */ 340 | public function bundleReorder($bundleLink, $link) 341 | { 342 | return $this->make('bundle/reorder', array( 343 | 'bundle_link' => $bundleLink, 344 | 'link' => $link, 345 | )); 346 | } 347 | 348 | /** 349 | * Get the number of views for a bundle. 350 | * 351 | * @param string $bundleLink 352 | * @return type 353 | */ 354 | public function bundleViewCount($bundleLink) 355 | { 356 | return $this->make('bundle/view_count', array( 357 | 'bundle_link' => $bundleLink, 358 | )); 359 | } 360 | 361 | /** 362 | * Given a bitly URL or hash (or multiple), returns the target (long) URL. 363 | * 364 | * @param string $shortURLOrHash 365 | * @return type 366 | */ 367 | public function expand($shortURLOrHash) 368 | { 369 | $params = array(); 370 | 371 | if (filter_var($shortURLOrHash, FILTER_VALIDATE_URL) === true) { 372 | $params['shortUrl'] = $shortURLOrHash; 373 | } else { 374 | $params['hash'] = $shortURLOrHash; 375 | } 376 | 377 | return $this->make('expand', $params); 378 | } 379 | 380 | /** 381 | * Returns a specified number of "high-value" bitly links that are popular across bitly at this particular moment. 382 | * 383 | * @param integer $limit 384 | * @return type 385 | */ 386 | public function highvalue($limit = null) 387 | { 388 | $params = array(); 389 | 390 | if ($limit !== null) { 391 | $params['limit'] = $limit; 392 | } 393 | 394 | return $this->make('highvalue', $params); 395 | } 396 | 397 | /** 398 | * This is used to return the page title for a given bitly link. 399 | * 400 | * @param string $hash 401 | * @param string $shortURL 402 | * @param boolean $expandUser 403 | * @return type 404 | */ 405 | public function info($shortURLOrHash, $expandUser = null) 406 | { 407 | $params = array(); 408 | 409 | if (filter_var($shortURLOrHash, FILTER_VALIDATE_URL) === true) { 410 | $params['shortUrl'] = $shortURLOrHash; 411 | } else { 412 | $params['hash'] = $shortURLOrHash; 413 | } 414 | 415 | if ($expandUser !== null) { 416 | $params['expand_user'] = $expandUser; 417 | } 418 | 419 | return $this->make('info', $params); 420 | } 421 | 422 | /** 423 | * Returns the detected categories for a document, in descending order of confidence. 424 | * 425 | * @param string $link 426 | * @return type 427 | */ 428 | public function linkCategory($link) 429 | { 430 | return $this->make('link/category', array( 431 | 'link' => $link, 432 | )); 433 | } 434 | 435 | /** 436 | * Returns the number of clicks on a single bitly link. 437 | * 438 | * @param string $link 439 | * @param string $unit 440 | * @param integer $units 441 | * @param string $timezone 442 | * @param boolean $rollup 443 | * @param integer $limit 444 | * @param integer $unitReferenceTimeStamp 445 | * @return type 446 | */ 447 | public function linkClicks($link, $unit = null, $units = null, $timezone = null, $rollup = null, $limit = null, $unitReferenceTimeStamp = null) 448 | { 449 | $params = array('link' => $link); 450 | 451 | if ($unit !== null) { 452 | $params['unit'] = $unit; 453 | } 454 | 455 | if ($units !== null) { 456 | $params['units'] = $units; 457 | } 458 | 459 | if ($timezone !== null) { 460 | $params['timezone'] = $timezone; 461 | } 462 | 463 | if ($rollup !== null) { 464 | $params['rollup'] = $rollup; 465 | } 466 | 467 | if ($limit !== null) { 468 | $params['limit'] = $limit; 469 | } 470 | 471 | if ($unitReferenceTimeStamp !== null) { 472 | $params['unit_reference_ts'] = $unitReferenceTimeStamp; 473 | } 474 | 475 | return $this->make('link/clicks', $params); 476 | } 477 | 478 | /** 479 | * Returns the “main article” from the linked page, as determined by the content extractor, in either HTML or plain text format. 480 | * 481 | * @param string $link 482 | * @param string $contentType 483 | * @return type 484 | */ 485 | public function linkContent($link, $contentType = null) 486 | { 487 | $params = array('link' => $link); 488 | 489 | if ($contentType !== null) { 490 | $params['content_type'] = $contentType; 491 | } 492 | 493 | return $this->make('link/content', $params); 494 | } 495 | 496 | /** 497 | * Returns metrics about the countries referring click traffic to a single bitly link. 498 | * 499 | * @param string $link 500 | * @param string $unit 501 | * @param integer $units 502 | * @param string $timezone 503 | * @param integer $limit 504 | * @param integer $unitReferenceTimeStamp 505 | * @return type 506 | */ 507 | public function linkCountries($link, $unit = null, $units = null, $timezone = null, $limit = null, $unitReferenceTimeStamp = null) 508 | { 509 | $params = array('link' => $link); 510 | 511 | if ($unit !== null) { 512 | $params['unit'] = $unit; 513 | } 514 | 515 | if ($units !== null) { 516 | $params['units'] = $units; 517 | } 518 | 519 | if ($timezone !== null) { 520 | $params['timezone'] = $timezone; 521 | } 522 | 523 | if ($limit !== null) { 524 | $params['limit'] = $limit; 525 | } 526 | 527 | if ($unitReferenceTimeStamp !== null) { 528 | $params['unit_reference_ts'] = $unitReferenceTimeStamp; 529 | } 530 | 531 | return $this->make('link/countries', $params); 532 | } 533 | 534 | /** 535 | * Returns users who have encoded this link (optionally only those in the requesting user's social graph). 536 | * Note: Some users may not be returned from this call depending on link privacy settings. 537 | * 538 | * @param string $link 539 | * @param boolean $myNetwork 540 | * @param boolean $subaccounts 541 | * @param integer $limit 542 | * @param boolean $expandUser 543 | * @return type 544 | */ 545 | public function linkEncoders($link, $myNetwork = null, $subaccounts = null, $limit = null, $expandUser = null) 546 | { 547 | $params = array('link' => $link); 548 | 549 | if ($myNetwork !== null) { 550 | $params['my_network'] = $myNetwork; 551 | } 552 | 553 | if ($subaccounts !== null) { 554 | $params['subaccounts'] = $subaccounts; 555 | } 556 | 557 | if ($limit !== null) { 558 | $params['limit'] = $limit; 559 | } 560 | 561 | if ($expandUser !== null) { 562 | $params['expand_user'] = $expandUser; 563 | } 564 | 565 | return $this->make('link/encoders', $params); 566 | } 567 | 568 | /** 569 | * Returns users who have encoded this link (optionally only those in the requesting user's social graph), sorted by the number of clicks on each encoding user's link. 570 | * Note: The response will only contain users whose links have gotten at least one click, and will not contain any users whose links are private. 571 | * 572 | * @param string $link 573 | * @param boolean $myNetwork 574 | * @param boolean $subaccounts 575 | * @param integer $limit 576 | * @param boolean $expandUser 577 | * @return type 578 | */ 579 | public function linkEncodersByCount($link, $myNetwork = null, $subaccounts = null, $limit = null, $expandUser = null) 580 | { 581 | $params = array('link' => $link); 582 | 583 | if ($myNetwork !== null) { 584 | $params['my_network'] = $myNetwork; 585 | } 586 | 587 | if ($subaccounts !== null) { 588 | $params['subaccounts'] = $subaccounts; 589 | } 590 | 591 | if ($limit !== null) { 592 | $params['limit'] = $limit; 593 | } 594 | 595 | if ($expandUser !== null) { 596 | $params['expand_user'] = $expandUser; 597 | } 598 | 599 | return $this->make('link/encoders_by_count', $params); 600 | } 601 | 602 | /** 603 | * Returns the number of users who have shortened (encoded) a single bitly link. 604 | * 605 | * @param string $link 606 | * @return type 607 | */ 608 | public function linkEncodersCount($link) 609 | { 610 | return $this->make('link/encoders_count', array( 611 | 'link' => $link, 612 | )); 613 | } 614 | 615 | /** 616 | * Returns metadata about a single bitly link. 617 | * 618 | * @param string $link 619 | * @return type 620 | */ 621 | public function linkInfo($link) 622 | { 623 | return $this->make('link/info', array( 624 | 'link' => $link, 625 | )); 626 | } 627 | 628 | /** 629 | * Returns the significant languages for the bitly link. Note that languages are highly dependent upon activity (clicks) occurring on the bitly link. If there have not been clicks on a bitly link within the last 24 hours, it is possible that language data for that link does not exist. 630 | * 631 | * @param string $link 632 | * @return type 633 | */ 634 | public function linkLanguage($link) 635 | { 636 | return $this->make('link/language', array( 637 | 'link' => $link, 638 | )); 639 | } 640 | 641 | /** 642 | * Returns the significant locations for the bitly link or None if locations do not exist. Note that locations are highly dependent upon activity (clicks) occurring on the bitly link. If there have not been clicks on a bitly link within the last 24 hours, it is possible that location data for that link does not exist. 643 | * 644 | * @param string $link 645 | * @return type 646 | */ 647 | public function linkLocation($link) 648 | { 649 | return $this->make('link/location', array( 650 | 'link' => $link, 651 | )); 652 | } 653 | 654 | /** 655 | * This is used to query for a bitly link based on a long URL. 656 | * 657 | * @param string $url 658 | * @return type 659 | */ 660 | public function linkLookup($url) 661 | { 662 | return $this->make('link/lookup', array( 663 | 'url' => $url, 664 | )); 665 | } 666 | 667 | /** 668 | * 669 | * Returns metrics about the pages referring click traffic to a single bitly link. 670 | * 671 | * @param string $link 672 | * @param string $unit 673 | * @param integer $units 674 | * @param string $timezone 675 | * @param integer $limit 676 | * @param integer $unitReferenceTimeStamp 677 | * @return type 678 | */ 679 | public function linkReferrers($link, $unit = null, $units = null, $timezone = null, $limit = null, $unitReferenceTimeStamp = null) 680 | { 681 | $params = array('link' => $link); 682 | 683 | if ($unit !== null) { 684 | $params['unit'] = $unit; 685 | } 686 | 687 | if ($units !== null) { 688 | $params['units'] = $units; 689 | } 690 | 691 | if ($timezone !== null) { 692 | $params['timezone'] = $timezone; 693 | } 694 | 695 | if ($limit !== null) { 696 | $params['limit'] = $limit; 697 | } 698 | 699 | if ($unitReferenceTimeStamp !== null) { 700 | $params['unit_reference_ts'] = $unitReferenceTimeStamp; 701 | } 702 | 703 | return $this->make('link/referrers', $params); 704 | } 705 | 706 | /** 707 | * Returns metrics about the pages referring click traffic to a single bitly link, grouped by referring domain. 708 | * 709 | * @param string $link 710 | * @param string $unit 711 | * @param integer $units 712 | * @param string $timezone 713 | * @param integer $limit 714 | * @param integer $unitReferenceTimeStamp 715 | * @return type 716 | */ 717 | public function linkReferrersByDomain($link, $unit = null, $units = null, $timezone = null, $limit = null, $unitReferenceTimeStamp = null) 718 | { 719 | $params = array('link' => $link); 720 | 721 | if ($unit !== null) { 722 | $params['unit'] = $unit; 723 | } 724 | 725 | if ($units !== null) { 726 | $params['units'] = $units; 727 | } 728 | 729 | if ($timezone !== null) { 730 | $params['timezone'] = $timezone; 731 | } 732 | 733 | if ($limit !== null) { 734 | $params['limit'] = $limit; 735 | } 736 | 737 | if ($unitReferenceTimeStamp !== null) { 738 | $params['unit_reference_ts'] = $unitReferenceTimeStamp; 739 | } 740 | 741 | return $this->make('link/referrers_by_domain', $params); 742 | } 743 | 744 | /** 745 | * Returns metrics about the domains referring click traffic to a single bitly link. 746 | * 747 | * @param string $link 748 | * @param string $unit 749 | * @param integer $units 750 | * @param string $timezone 751 | * @param integer $limit 752 | * @param integer $unitReferenceTimeStamp 753 | * @return type 754 | */ 755 | public function linkReferringDomains($link, $unit = null, $units = null, $timezone = null, $limit = null, $unitReferenceTimeStamp = null) 756 | { 757 | $params = array('link' => $link); 758 | 759 | if ($unit !== null) { 760 | $params['unit'] = $unit; 761 | } 762 | 763 | if ($units !== null) { 764 | $params['units'] = $units; 765 | } 766 | 767 | if ($timezone !== null) { 768 | $params['timezone'] = $timezone; 769 | } 770 | 771 | if ($limit !== null) { 772 | $params['limit'] = $limit; 773 | } 774 | 775 | if ($unitReferenceTimeStamp !== null) { 776 | $params['unit_reference_ts'] = $unitReferenceTimeStamp; 777 | } 778 | 779 | return $this->make('link/referring_domains', $params); 780 | } 781 | 782 | /** 783 | * Returns metrics about a shares of a single link. 784 | * 785 | * @param string $link 786 | * @param string $unit 787 | * @param integer $units 788 | * @param string $timezone 789 | * @param boolean $rollup 790 | * @param integer $limit 791 | * @param integer $unitReferenceTimeStamp 792 | * @return type 793 | */ 794 | public function linkShares($link, $unit = null, $units = null, $timezone = null, $rollup = null, $limit = null, $unitReferenceTimeStamp = null) 795 | { 796 | $params = array('link' => $link); 797 | 798 | if ($unit !== null) { 799 | $params['unit'] = $unit; 800 | } 801 | 802 | if ($units !== null) { 803 | $params['units'] = $units; 804 | } 805 | 806 | if ($timezone !== null) { 807 | $params['timezone'] = $timezone; 808 | } 809 | 810 | if ($limit !== null) { 811 | $params['limit'] = $limit; 812 | } 813 | 814 | if ($unitReferenceTimeStamp !== null) { 815 | $params['unit_reference_ts'] = $unitReferenceTimeStamp; 816 | } 817 | 818 | return $this->make('link/shares', $params); 819 | } 820 | 821 | /** 822 | * Returns the "social score" for a specified bitly link. Note that the social score are highly dependent upon activity (clicks) occurring on the bitly link. If there have not been clicks on a bitly link within the last 24 hours, it is possible a social score for that link does not exist. 823 | * 824 | * @param string $link 825 | * @return type 826 | */ 827 | public function linkSocial($link) 828 | { 829 | return $this->make('link/social', array( 830 | 'link' => $link, 831 | )); 832 | } 833 | 834 | /** 835 | * Return information about an OAuth app. 836 | * 837 | * @param string $clientId 838 | * @return type 839 | */ 840 | public function oAuthApp($clientId) 841 | { 842 | return $this->make('oauth/app', array( 843 | 'client_id' => $clientId, 844 | )); 845 | } 846 | 847 | /** 848 | * Returns the top links shared by you, but not by your audience, ordered by clicks. 849 | * This endpoint is only available to paid customers. 850 | * 851 | * @param string $domain 852 | * @param string $unit 853 | * @param integer $units 854 | * @param string $timezone 855 | * @param integer $limit 856 | * @param integer $unitReferenceTimeStamp 857 | * @return type 858 | */ 859 | public function organizationBrandMessages($domain = null, $unit = null, $units = null, $timezone = null, $limit = null, $unitReferenceTimeStamp = null) 860 | { 861 | $params = array(); 862 | 863 | if ($domain !== null) { 864 | $params['domain'] = $domain; 865 | } 866 | 867 | if ($unit !== null) { 868 | $params['unit'] = $unit; 869 | } 870 | 871 | if ($units !== null) { 872 | $params['units'] = $units; 873 | } 874 | 875 | if ($timezone !== null) { 876 | $params['timezone'] = $timezone; 877 | } 878 | 879 | if ($limit !== null) { 880 | $params['limit'] = $limit; 881 | } 882 | 883 | if ($unitReferenceTimeStamp !== null) { 884 | $params['unit_reference_ts'] = $unitReferenceTimeStamp; 885 | } 886 | 887 | return $this->make('organization/brand_messages', $params); 888 | } 889 | 890 | /** 891 | * Returns the top links shared by both your audience and by your account, ordered by clicks. 892 | * This endpoint is only available to paid customers. 893 | * 894 | * @param string $domain 895 | * @param string $unit 896 | * @param integer $units 897 | * @param string $timezone 898 | * @param integer $limit 899 | * @param integer $unitReferenceTimeStamp 900 | * @return type 901 | */ 902 | public function organizationIntersectingLinks($domain = null, $unit = null, $units = null, $timezone = null, $limit = null, $unitReferenceTimeStamp = null) 903 | { 904 | $params = array(); 905 | 906 | if ($domain !== null) { 907 | $params['domain'] = $domain; 908 | } 909 | 910 | if ($unit !== null) { 911 | $params['unit'] = $unit; 912 | } 913 | 914 | if ($units !== null) { 915 | $params['units'] = $units; 916 | } 917 | 918 | if ($timezone !== null) { 919 | $params['timezone'] = $timezone; 920 | } 921 | 922 | if ($limit !== null) { 923 | $params['limit'] = $limit; 924 | } 925 | 926 | if ($unitReferenceTimeStamp !== null) { 927 | $params['unit_reference_ts'] = $unitReferenceTimeStamp; 928 | } 929 | 930 | return $this->make('organization/interesecting_links', $params); 931 | } 932 | 933 | /** 934 | * Returns the top-performing organization members ordered by clicks or shortens. 935 | * This endpoint is only available to paid customers. 936 | * 937 | * @param string $domain 938 | * @param string $orderBy 939 | * @param string $unit 940 | * @param integer $units 941 | * @param string $timezone 942 | * @param integer $limit 943 | * @param integer $unitReferenceTimeStamp 944 | * @return type 945 | */ 946 | public function organizationLeaderboard($domain = null, $orderBy = null, $unit = null, $units = null, $timezone = null, $limit = null, $unitReferenceTimeStamp = null) 947 | { 948 | $params = array(); 949 | 950 | if ($domain !== null) { 951 | $params['domain'] = $domain; 952 | } 953 | 954 | if ($orderBy !== null) { 955 | $params['order_by'] = $orderBy; 956 | } 957 | 958 | if ($unit !== null) { 959 | $params['unit'] = $unit; 960 | } 961 | 962 | if ($units !== null) { 963 | $params['units'] = $units; 964 | } 965 | 966 | if ($timezone !== null) { 967 | $params['timezone'] = $timezone; 968 | } 969 | 970 | if ($limit !== null) { 971 | $params['limit'] = $limit; 972 | } 973 | 974 | if ($unitReferenceTimeStamp !== null) { 975 | $params['unit_reference_ts'] = $unitReferenceTimeStamp; 976 | } 977 | 978 | return $this->make('organization/leaderboard', $params); 979 | } 980 | 981 | /** 982 | * Returns the top links shared by your audience, but not by you, ordered by clicks. 983 | * This endpoint is only available to paid customers. 984 | * 985 | * @param string $domain 986 | * @param string $unit 987 | * @param integer $units 988 | * @param string $timezone 989 | * @param integer $limit 990 | * @param integer $unitReferenceTimeStamp 991 | * @return type 992 | */ 993 | public function organizationMissedOpportunities($domain = null, $unit = null, $units = null, $timezone = null, $limit = null, $unitReferenceTimeStamp = null) 994 | { 995 | $params = array(); 996 | 997 | if ($domain !== null) { 998 | $params['domain'] = $domain; 999 | } 1000 | 1001 | if ($unit !== null) { 1002 | $params['unit'] = $unit; 1003 | } 1004 | 1005 | if ($units !== null) { 1006 | $params['units'] = $units; 1007 | } 1008 | 1009 | if ($timezone !== null) { 1010 | $params['timezone'] = $timezone; 1011 | } 1012 | 1013 | if ($limit !== null) { 1014 | $params['limit'] = $limit; 1015 | } 1016 | 1017 | if ($unitReferenceTimeStamp !== null) { 1018 | $params['unit_reference_ts'] = $unitReferenceTimeStamp; 1019 | } 1020 | 1021 | return $this->make('organization/missed_opportunities', $params); 1022 | } 1023 | 1024 | /** 1025 | * Returns phrases that are receiving an uncharacteristically high volume of click traffic, and the individual links (hashes) driving traffic to pages containing these phrases. 1026 | * 1027 | * @return type 1028 | */ 1029 | public function realtimeBurstingPhrases() 1030 | { 1031 | return $this->make('realtime/bursting_phrases'); 1032 | } 1033 | 1034 | /** 1035 | * Returns the click rate for content containing a specified phrase. 1036 | * 1037 | * @param string $phrase 1038 | * @return type 1039 | */ 1040 | public function realtimeClickrate($phrase) 1041 | { 1042 | return $this->make('realtime/clickrate', array( 1043 | 'phrase' => $phrase, 1044 | )); 1045 | } 1046 | 1047 | /** 1048 | * Returns phrases that are receiving a consistently high volume of click traffic, and the individual links (hashes) driving traffic to pages containing these phrases. 1049 | * 1050 | * @return type 1051 | */ 1052 | public function realtimeHotPhrases() 1053 | { 1054 | return $this->make('realtime/hot_phrases'); 1055 | } 1056 | 1057 | /** 1058 | * Search links receiving clicks across bitly by content, language, location, and more. 1059 | * 1060 | * @param string $query 1061 | * @param string $fields 1062 | * @param integer $offset 1063 | * @param integer $limit 1064 | * @param string $domain 1065 | * @param string $fullDomain 1066 | * @param string $cities 1067 | * @param string $lang 1068 | * @return type 1069 | */ 1070 | public function search($query, $domain, $fields = null, $offset = null, $limit = null, $fullDomain = null, $cities = null, $lang = null) 1071 | { 1072 | $params = array( 1073 | 'query' => $query, 1074 | 'domain' => $domain, 1075 | ); 1076 | 1077 | if ($fields !== null) { 1078 | $params['fields'] = $fields; 1079 | } 1080 | 1081 | if ($offset !== null) { 1082 | $params['offset'] = $offset; 1083 | } 1084 | 1085 | if ($limit !== null) { 1086 | $params['limit'] = $limit; 1087 | } 1088 | 1089 | if ($fullDomain !== null) { 1090 | $params['full_domain'] = $fullDomain; 1091 | } 1092 | 1093 | if ($cities !== null) { 1094 | $params['cities'] = $cities; 1095 | } 1096 | 1097 | if ($lang !== null) { 1098 | $params['lang'] = $lang; 1099 | } 1100 | 1101 | return $this->make('search', $params); 1102 | } 1103 | 1104 | /** 1105 | * Given a long URL, returns a bitly short URL. 1106 | * 1107 | * @param string $longURL 1108 | * @param type $domain 1109 | * @return type 1110 | */ 1111 | public function shorten($longURL, $domain = null) 1112 | { 1113 | $params = array('longUrl' => $longURL); 1114 | 1115 | if ($domain !== null) { 1116 | $params['domain'] = $domain; 1117 | } 1118 | 1119 | return $this->make('shorten', $params); 1120 | } 1121 | 1122 | /** 1123 | * Returns the aggregate number of clicks on all of the authenticated user's bitly links. 1124 | * 1125 | * @param string $unit 1126 | * @param integer $units 1127 | * @param string $timezone 1128 | * @param boolean $rollup 1129 | * @param integer $limit 1130 | * @param integer $unitReferenceTimeStamp 1131 | * @return type 1132 | */ 1133 | public function userClicks($unit = null, $units = null, $timezone = null, $rollup = null, $limit = null, $unitReferenceTimeStamp = null) 1134 | { 1135 | $params = array(); 1136 | 1137 | if ($unit !== null) { 1138 | $params['unit'] = $unit; 1139 | } 1140 | 1141 | if ($units !== null) { 1142 | $params['units'] = $units; 1143 | } 1144 | 1145 | if ($timezone !== null) { 1146 | $params['timezone'] = $timezone; 1147 | } 1148 | 1149 | if ($rollup !== null) { 1150 | $params['rollup'] = $rollup; 1151 | } 1152 | 1153 | if ($limit !== null) { 1154 | $params['limit'] = $limit; 1155 | } 1156 | 1157 | if ($unitReferenceTimeStamp !== null) { 1158 | $params['unit_reference_ts'] = $unitReferenceTimeStamp; 1159 | } 1160 | 1161 | return $this->make('user/clicks', $params); 1162 | } 1163 | 1164 | /** 1165 | * Returns aggregate metrics about the countries referring click traffic to all of the authenticated user's bitly links. 1166 | * 1167 | * @param string $unit 1168 | * @param integer $units 1169 | * @param string $timezone 1170 | * @param boolean $rollup 1171 | * @param integer $limit 1172 | * @param integer $unitReferenceTimeStamp 1173 | * @return type 1174 | */ 1175 | public function userCountries($unit = null, $units = null, $timezone = null, $rollup = null, $limit = null, $unitReferenceTimeStamp = null) 1176 | { 1177 | $params = array(); 1178 | 1179 | if ($unit !== null) { 1180 | $params['unit'] = $unit; 1181 | } 1182 | 1183 | if ($units !== null) { 1184 | $params['units'] = $units; 1185 | } 1186 | 1187 | if ($timezone !== null) { 1188 | $params['timezone'] = $timezone; 1189 | } 1190 | 1191 | if ($rollup !== null) { 1192 | $params['rollup'] = $rollup; 1193 | } 1194 | 1195 | if ($limit !== null) { 1196 | $params['limit'] = $limit; 1197 | } 1198 | 1199 | if ($unitReferenceTimeStamp !== null) { 1200 | $params['unit_reference_ts'] = $unitReferenceTimeStamp; 1201 | } 1202 | 1203 | return $this->make('user/countries', $params); 1204 | } 1205 | 1206 | /** 1207 | * Return or update information about a user. 1208 | * 1209 | * @param string $login 1210 | * @param string $fullName 1211 | * @return type 1212 | */ 1213 | public function userInfo($login = null, $fullName = null) 1214 | { 1215 | $params = array(); 1216 | 1217 | if ($login !== null) { 1218 | $params['login'] = $login; 1219 | } 1220 | 1221 | if ($fullName !== null) { 1222 | $params['full_name'] = $fullName; 1223 | } 1224 | 1225 | return $this->make('user/info', $params); 1226 | } 1227 | 1228 | /** 1229 | * Changes link metadata in a user's history. 1230 | * 1231 | * @param string $link 1232 | * @param string $edit 1233 | * @param string $title 1234 | * @param string $note 1235 | * @param boolean $private 1236 | * @param integer $userTimeStamp 1237 | * @param boolean $archived 1238 | * @return type 1239 | */ 1240 | public function userLinkEdit($link, $edit, $title = null, $note = null, $private = null, $userTimeStamp = null, $archived = null) 1241 | { 1242 | $params = array( 1243 | 'link' => $link, 1244 | 'edit' => $edit, 1245 | ); 1246 | 1247 | if ($title !== null) { 1248 | $params['title'] = $title; 1249 | } 1250 | 1251 | if ($note !== null) { 1252 | $params['note'] = $note; 1253 | } 1254 | 1255 | if ($private !== null) { 1256 | $params['private'] = $private; 1257 | } 1258 | 1259 | if ($userTimeStamp !== null) { 1260 | $params['user_ts'] = $userTimeStamp; 1261 | } 1262 | 1263 | if ($archived !== null) { 1264 | $params['archived'] = $archived; 1265 | } 1266 | 1267 | return $this->make('user/link_edit', $params); 1268 | } 1269 | 1270 | /** 1271 | * Returns entries from a user's link history in reverse chronological order. 1272 | * Note: Entries will be sorted by the user_ts field found in the response data. 1273 | * 1274 | * @param string $link 1275 | * @param string $query 1276 | * @param integer $offset 1277 | * @param integer $limit 1278 | * @param integer $createdBefore 1279 | * @param integer $createdAfter 1280 | * @param integer $modifiedAfter 1281 | * @param boolean $expandClientId 1282 | * @param string $archived 1283 | * @param string $private 1284 | * @param string $user 1285 | * @param string $exactDomain 1286 | * @param string $rootDomain 1287 | * @return type 1288 | */ 1289 | public function userLinkHistory($link = null, $query = null, $offset = null, $limit = null, $createdBefore = null, $createdAfter = null, $modifiedAfter = null, $expandClientId = null, $archived = null, $private = null, $user = null, $exactDomain = null, $rootDomain = null) 1290 | { 1291 | $params = array(); 1292 | 1293 | if ($link !== null) { 1294 | $params['link'] = $link; 1295 | } 1296 | 1297 | if ($query !== null) { 1298 | $params['query'] = $query; 1299 | } 1300 | 1301 | if ($offset !== null) { 1302 | $params['offset'] = $offset; 1303 | } 1304 | 1305 | if ($limit !== null) { 1306 | $params['limit'] = $limit; 1307 | } 1308 | 1309 | if ($createdBefore !== null) { 1310 | $params['created_before'] = $createdBefore; 1311 | } 1312 | 1313 | if ($createdAfter !== null) { 1314 | $params['created_after'] = $createdAfter; 1315 | } 1316 | 1317 | if ($modifiedAfter !== null) { 1318 | $params['modified_after'] = $modifiedAfter; 1319 | } 1320 | 1321 | if ($expandClientId !== null) { 1322 | $params['expand_client_id'] = $expandClientId; 1323 | } 1324 | 1325 | if ($archived !== null) { 1326 | $params['archived'] = $archived; 1327 | } 1328 | 1329 | if ($private !== null) { 1330 | $params['private'] = $private; 1331 | } 1332 | 1333 | if ($offset !== null) { 1334 | $params['offset'] = $offset; 1335 | } 1336 | 1337 | if ($user !== null) { 1338 | $params['user'] = $user; 1339 | } 1340 | 1341 | if ($exactDomain !== null) { 1342 | $params['exact_domain'] = $exactDomain; 1343 | } 1344 | 1345 | if ($rootDomain !== null) { 1346 | $params['root_domain'] = $rootDomain; 1347 | } 1348 | 1349 | return $this->make('user/link_history', $params); 1350 | } 1351 | 1352 | /** 1353 | * This is used to query for a bitly link shortened by the authenticated user based on a long URL. 1354 | * 1355 | * @param string $url 1356 | * @return type 1357 | */ 1358 | public function userLinkLookup($url) 1359 | { 1360 | return $this->make('user/link_lookup', array( 1361 | 'url' => $url, 1362 | )); 1363 | } 1364 | 1365 | /** 1366 | * Saves a link as a bitmark in a user's history, with optional pre-set metadata. (Also returns a short URL for that link.) 1367 | * 1368 | * @param string $longURL 1369 | * @param string $title 1370 | * @param string $note 1371 | * @param boolean $private 1372 | * @param integer $userTimeStamp 1373 | * @return type 1374 | */ 1375 | public function userLinkSave($longURL, $title = null, $note = null, $private = null, $userTimeStamp = null) 1376 | { 1377 | $params = array('longUrl' => $longURL); 1378 | 1379 | if ($title !== null) { 1380 | $params['title'] = $title; 1381 | } 1382 | 1383 | if ($note !== null) { 1384 | $params['note'] = $note; 1385 | } 1386 | 1387 | if ($private !== null) { 1388 | $params['private'] = $private; 1389 | } 1390 | 1391 | if ($userTimeStamp !== null) { 1392 | $params['user_ts'] = $userTimeStamp; 1393 | } 1394 | 1395 | return $this->make('user/link_save', $params); 1396 | } 1397 | 1398 | /** 1399 | * Returns entries from a user's network history in reverse chronogical order. (A user's network history includes publicly saved links from Twitter and Facebook connections.) 1400 | * 1401 | * @param integer $offset 1402 | * @param boolean $expandClientId 1403 | * @param integer $limit 1404 | * @param boolean $expandUser 1405 | * @return type 1406 | */ 1407 | public function userNetworkHistory($offset = null, $expandClientId = null, $limit = null, $expandUser = null) 1408 | { 1409 | $params = array(); 1410 | 1411 | if ($offset !== null) { 1412 | $params['offset'] = $offset; 1413 | } 1414 | 1415 | if ($expandClientId !== null) { 1416 | $params['expand_client_id'] = $expandClientId; 1417 | } 1418 | 1419 | if ($limit !== null) { 1420 | $params['limit'] = $limit; 1421 | } 1422 | 1423 | if ($expandUser !== null) { 1424 | $params['expand_user'] = $expandUser; 1425 | } 1426 | 1427 | return $this->make('user/newtork_history', $params); 1428 | } 1429 | 1430 | /** 1431 | * Returns the top links to your tracking domain (or domains) created by users not associated with your account, ordered by clicks. 1432 | * Users can register a tracking domain from their bitly settings page. 1433 | * This endpoint is only available to paid customers. 1434 | * 1435 | * @param string $domain 1436 | * @param string $unit 1437 | * @param integer $units 1438 | * @param string $timezone 1439 | * @param integer $limit 1440 | * @param integer $unitReferenceTimeStamp 1441 | * @return type 1442 | */ 1443 | public function userPopularEarnedByClicks($domain = null, $unit = null, $units = null, $timezone = null, $limit = null, $unitReferenceTimeStamp = null) 1444 | { 1445 | $params = array(); 1446 | 1447 | if ($domain !== null) { 1448 | $params['domain'] = $domain; 1449 | } 1450 | 1451 | if ($unit !== null) { 1452 | $params['unit'] = $unit; 1453 | } 1454 | 1455 | if ($units !== null) { 1456 | $params['units'] = $units; 1457 | } 1458 | 1459 | if ($timezone !== null) { 1460 | $params['timezone'] = $timezone; 1461 | } 1462 | 1463 | if ($limit !== null) { 1464 | $params['limit'] = $limit; 1465 | } 1466 | 1467 | if ($unitReferenceTimeStamp !== null) { 1468 | $params['unit_reference_ts'] = $unitReferenceTimeStamp; 1469 | } 1470 | 1471 | return $this->make('user/popular_earned_by_clicks', $params); 1472 | } 1473 | 1474 | /** 1475 | * Returns the top links to your tracking domain (or domains) created by users not associated with your account, ordered by shortens. 1476 | * Users can register a tracking domain from their bitly settings page. 1477 | * This endpoint is only available to paid customers. 1478 | * 1479 | * @param string $domain 1480 | * @param string $unit 1481 | * @param integer $units 1482 | * @param string $timezone 1483 | * @param integer $limit 1484 | * @param integer $unitReferenceTimeStamp 1485 | * @return type 1486 | */ 1487 | public function userPopularEarnedByShortens($domain = null, $unit = null, $units = null, $timezone = null, $limit = null, $unitReferenceTimeStamp = null) 1488 | { 1489 | $params = array(); 1490 | 1491 | if ($domain !== null) { 1492 | $params['domain'] = $domain; 1493 | } 1494 | 1495 | if ($unit !== null) { 1496 | $params['unit'] = $unit; 1497 | } 1498 | 1499 | if ($units !== null) { 1500 | $params['units'] = $units; 1501 | } 1502 | 1503 | if ($timezone !== null) { 1504 | $params['timezone'] = $timezone; 1505 | } 1506 | 1507 | if ($limit !== null) { 1508 | $params['limit'] = $limit; 1509 | } 1510 | 1511 | if ($unitReferenceTimeStamp !== null) { 1512 | $params['unit_reference_ts'] = $unitReferenceTimeStamp; 1513 | } 1514 | 1515 | return $this->make('user/popular_earned_by_shortens', $params); 1516 | } 1517 | 1518 | /** 1519 | * Returns the authenticated user's most-clicked bitly links (ordered by number of clicks) in a given time period. 1520 | * Note: This replaces the realtime_links endpoint. 1521 | * 1522 | * @param string $unit 1523 | * @param integer $units 1524 | * @param string $timezone 1525 | * @param integer $limit 1526 | * @param integer $unitReferenceTimeStamp 1527 | * @return type 1528 | */ 1529 | public function userPopularLinks($unit = null, $units = null, $timezone = null, $limit = null, $unitReferenceTimeStamp = null) 1530 | { 1531 | $params = array(); 1532 | 1533 | if ($unit !== null) { 1534 | $params['unit'] = $unit; 1535 | } 1536 | 1537 | if ($units !== null) { 1538 | $params['units'] = $units; 1539 | } 1540 | 1541 | if ($timezone !== null) { 1542 | $params['timezone'] = $timezone; 1543 | } 1544 | 1545 | if ($limit !== null) { 1546 | $params['limit'] = $limit; 1547 | } 1548 | 1549 | if ($unitReferenceTimeStamp !== null) { 1550 | $params['unit_reference_ts'] = $unitReferenceTimeStamp; 1551 | } 1552 | 1553 | return $this->make('user/popular_links', $params); 1554 | } 1555 | 1556 | /** 1557 | * Returns the top links to your tracking domain (or domains) created by you or your subaccounts ordered by clicks. 1558 | * Users can register a tracking domain from their bitly settings page. 1559 | * This endpoint is only available to paid customers. 1560 | * 1561 | * @param string $domain 1562 | * @param string $subaccount 1563 | * @param string $unit 1564 | * @param integer $units 1565 | * @param string $timezone 1566 | * @param integer $limit 1567 | * @param integer $unitReferenceTimeStamp 1568 | * @return type 1569 | */ 1570 | public function userPopularOwnedByClicks($domain = null, $subaccount = null, $unit = null, $units = null, $timezone = null, $limit = null, $unitReferenceTimeStamp = null) 1571 | { 1572 | $params = array(); 1573 | 1574 | if ($domain !== null) { 1575 | $params['domain'] = $domain; 1576 | } 1577 | 1578 | if ($subaccount !== null) { 1579 | $params['subaccount'] = $subaccount; 1580 | } 1581 | 1582 | if ($unit !== null) { 1583 | $params['unit'] = $unit; 1584 | } 1585 | 1586 | if ($units !== null) { 1587 | $params['units'] = $units; 1588 | } 1589 | 1590 | if ($timezone !== null) { 1591 | $params['timezone'] = $timezone; 1592 | } 1593 | 1594 | if ($limit !== null) { 1595 | $params['limit'] = $limit; 1596 | } 1597 | 1598 | if ($unitReferenceTimeStamp !== null) { 1599 | $params['unit_reference_ts'] = $unitReferenceTimeStamp; 1600 | } 1601 | 1602 | return $this->make('user/popular_owned_by_clicks', $params); 1603 | } 1604 | 1605 | /** 1606 | * Returns the top links to your tracking domain (or domains) created by you or your subaccounts ordered by number of shortens. 1607 | * Users can register a tracking domain from their bitly settings page. 1608 | * This endpoint is only available to paid customers. 1609 | * 1610 | * @param string $domain 1611 | * @param string $subaccount 1612 | * @param string $unit 1613 | * @param integer $units 1614 | * @param string $timezone 1615 | * @param integer $limit 1616 | * @param integer $unitReferenceTimeStamp 1617 | * @return type 1618 | */ 1619 | public function userPopularOwnedByShortens($domain = null, $subaccount = null, $unit = null, $units = null, $timezone = null, $limit = null, $unitReferenceTimeStamp = null) 1620 | { 1621 | $params = array(); 1622 | 1623 | if ($domain !== null) { 1624 | $params['domain'] = $domain; 1625 | } 1626 | 1627 | if ($subaccount !== null) { 1628 | $params['subaccount'] = $subaccount; 1629 | } 1630 | 1631 | if ($unit !== null) { 1632 | $params['unit'] = $unit; 1633 | } 1634 | 1635 | if ($units !== null) { 1636 | $params['units'] = $units; 1637 | } 1638 | 1639 | if ($timezone !== null) { 1640 | $params['timezone'] = $timezone; 1641 | } 1642 | 1643 | if ($limit !== null) { 1644 | $params['limit'] = $limit; 1645 | } 1646 | 1647 | if ($unitReferenceTimeStamp !== null) { 1648 | $params['unit_reference_ts'] = $unitReferenceTimeStamp; 1649 | } 1650 | 1651 | return $this->make('user/popular_owned_by_shortens', $params); 1652 | } 1653 | 1654 | /** 1655 | * Returns aggregate metrics about the pages referring click traffic to all of the authenticated user's bitly links. 1656 | * 1657 | * @param string $unit 1658 | * @param integer $units 1659 | * @param string $timezone 1660 | * @param boolean $rollup 1661 | * @param integer $limit 1662 | * @param integer $unitReferenceTimeStamp 1663 | * @return type 1664 | */ 1665 | public function userReferrers($unit = null, $units = null, $timezone = null, $rollup = null, $limit = null, $unitReferenceTimeStamp = null) 1666 | { 1667 | $params = array(); 1668 | 1669 | if ($unit !== null) { 1670 | $params['unit'] = $unit; 1671 | } 1672 | 1673 | if ($units !== null) { 1674 | $params['units'] = $units; 1675 | } 1676 | 1677 | if ($timezone !== null) { 1678 | $params['timezone'] = $timezone; 1679 | } 1680 | 1681 | if ($rollup !== null) { 1682 | $params['rollup'] = $rollup; 1683 | } 1684 | 1685 | if ($limit !== null) { 1686 | $params['limit'] = $limit; 1687 | } 1688 | 1689 | if ($unitReferenceTimeStamp !== null) { 1690 | $params['unit_reference_ts'] = $unitReferenceTimeStamp; 1691 | } 1692 | 1693 | return $this->make('user/referrers', $params); 1694 | } 1695 | 1696 | /** 1697 | * Returns aggregate metrics about the domains referring click traffic to all of the authenticated user's bitly links. 1698 | * 1699 | * @param string $unit 1700 | * @param integer $units 1701 | * @param string $timezone 1702 | * @param boolean $rollup 1703 | * @param integer $limit 1704 | * @param integer $unitReferenceTimeStamp 1705 | * @return type 1706 | */ 1707 | public function userReferringDomains($unit = null, $units = null, $timezone = null, $rollup = null, $limit = null, $unitReferenceTimeStamp = null) 1708 | { 1709 | $params = array(); 1710 | 1711 | if ($unit !== null) { 1712 | $params['unit'] = $unit; 1713 | } 1714 | 1715 | if ($units !== null) { 1716 | $params['units'] = $units; 1717 | } 1718 | 1719 | if ($timezone !== null) { 1720 | $params['timezone'] = $timezone; 1721 | } 1722 | 1723 | if ($rollup !== null) { 1724 | $params['rollup'] = $rollup; 1725 | } 1726 | 1727 | if ($limit !== null) { 1728 | $params['limit'] = $limit; 1729 | } 1730 | 1731 | if ($unitReferenceTimeStamp !== null) { 1732 | $params['unit_reference_ts'] = $unitReferenceTimeStamp; 1733 | } 1734 | 1735 | return $this->make('user/referring_domains', $params); 1736 | } 1737 | 1738 | /** 1739 | * Save a custom keyword for a custom short domain. 1740 | * 1741 | * @param string $keywordLink 1742 | * @param string $targetLink 1743 | * @return type 1744 | */ 1745 | public function userSaveCustomDomainKeyword($keywordLink, $targetLink) 1746 | { 1747 | return $this->make('user/save_custom_domain_keyword', array( 1748 | 'keyword_link' => $keywordLink, 1749 | 'target_link' => $targetLink, 1750 | )); 1751 | } 1752 | 1753 | /** 1754 | * Returns the number of shares by the authenticated user in a given time period. 1755 | * 1756 | * @param string $unit 1757 | * @param integer $units 1758 | * @param string $timezone 1759 | * @param boolean $rollup 1760 | * @param integer $limit 1761 | * @param integer $unitReferenceTimeStamp 1762 | * @return type 1763 | */ 1764 | public function userShareCounts($unit = null, $units = null, $timezone = null, $rollup = null, $limit = null, $unitReferenceTimeStamp = null) 1765 | { 1766 | $params = array(); 1767 | 1768 | if ($unit !== null) { 1769 | $params['unit'] = $unit; 1770 | } 1771 | 1772 | if ($units !== null) { 1773 | $params['units'] = $units; 1774 | } 1775 | 1776 | if ($timezone !== null) { 1777 | $params['timezone'] = $timezone; 1778 | } 1779 | 1780 | if ($rollup !== null) { 1781 | $params['rollup'] = $rollup; 1782 | } 1783 | 1784 | if ($limit !== null) { 1785 | $params['limit'] = $limit; 1786 | } 1787 | 1788 | if ($unitReferenceTimeStamp !== null) { 1789 | $params['unit_reference_ts'] = $unitReferenceTimeStamp; 1790 | } 1791 | 1792 | return $this->make('user/share_counts', $params); 1793 | } 1794 | 1795 | /** 1796 | * Returns the number of shares by the authenticated user, broken down by share type (ie: twitter, facebook, email) in a given time period. 1797 | * 1798 | * @param string $unit 1799 | * @param integer $units 1800 | * @param string $timezone 1801 | * @param boolean $rollup 1802 | * @param integer $limit 1803 | * @param integer $unitReferenceTimeStamp 1804 | * @return type 1805 | */ 1806 | public function userShareCountsByShareType($unit = null, $units = null, $timezone = null, $rollup = null, $limit = null, $unitReferenceTimeStamp = null) 1807 | { 1808 | $params = array(); 1809 | 1810 | if ($unit !== null) { 1811 | $params['unit'] = $unit; 1812 | } 1813 | 1814 | if ($units !== null) { 1815 | $params['units'] = $units; 1816 | } 1817 | 1818 | if ($timezone !== null) { 1819 | $params['timezone'] = $timezone; 1820 | } 1821 | 1822 | if ($rollup !== null) { 1823 | $params['rollup'] = $rollup; 1824 | } 1825 | 1826 | if ($limit !== null) { 1827 | $params['limit'] = $limit; 1828 | } 1829 | 1830 | if ($unitReferenceTimeStamp !== null) { 1831 | $params['unit_reference_ts'] = $unitReferenceTimeStamp; 1832 | } 1833 | 1834 | return $this->make('user/share_counts_by_share_type', $params); 1835 | } 1836 | 1837 | /** 1838 | * Returns the number of links shortened (encoded) in a given time period by the authenticated user. 1839 | * 1840 | * @param string $unit 1841 | * @param integer $units 1842 | * @param string $timezone 1843 | * @param boolean $rollup 1844 | * @param integer $limit 1845 | * @param integer $unitReferenceTimeStamp 1846 | * @return type 1847 | */ 1848 | public function userShortenCounts($unit = null, $units = null, $timezone = null, $rollup = null, $limit = null, $unitReferenceTimeStamp = null) 1849 | { 1850 | $params = array(); 1851 | 1852 | if ($unit !== null) { 1853 | $params['unit'] = $unit; 1854 | } 1855 | 1856 | if ($units !== null) { 1857 | $params['units'] = $units; 1858 | } 1859 | 1860 | if ($timezone !== null) { 1861 | $params['timezone'] = $timezone; 1862 | } 1863 | 1864 | if ($rollup !== null) { 1865 | $params['rollup'] = $rollup; 1866 | } 1867 | 1868 | if ($limit !== null) { 1869 | $params['limit'] = $limit; 1870 | } 1871 | 1872 | if ($unitReferenceTimeStamp !== null) { 1873 | $params['unit_reference_ts'] = $unitReferenceTimeStamp; 1874 | } 1875 | 1876 | return $this->make('user/shorten_counts', $params); 1877 | } 1878 | 1879 | /** 1880 | * Returns a list of tracking domains a user has configured. 1881 | * 1882 | * @return type 1883 | */ 1884 | public function userTrackingDomainList() 1885 | { 1886 | return $this->make('user/tracking_domain_list'); 1887 | } 1888 | 1889 | /** 1890 | * Query whether a given domain is a valid bitly pro domain. 1891 | * Keep in mind that bitly custom short domains are restricted 1892 | * to less than 15 characters in length. 1893 | * 1894 | * @param string $domain 1895 | * @return type 1896 | */ 1897 | public function domainBitlyProDomain($domain) 1898 | { 1899 | return $this->make('bitly_pro_domain', array( 1900 | 'domain' => $domain, 1901 | )); 1902 | } 1903 | 1904 | /** 1905 | * This lists NSQ Topic and Channel Message Information and Connection State for a Topic. 1906 | * 1907 | * @param type $topic NSQ Data Stream Topic 1908 | * @return type 1909 | */ 1910 | public function nsqStats($topic) 1911 | { 1912 | return $this->make('nsq/stats', array( 1913 | 'topic' => $topic, 1914 | )); 1915 | } 1916 | 1917 | /** 1918 | * Returns the number of clicks on Bitlinks pointing to the specified 1919 | * tracking domain that have occured in a given time period. 1920 | * Users can register a tracking domain from their bitly settings page. 1921 | * 1922 | * @param string $domain 1923 | * @param string $unit 1924 | * @param integer $units 1925 | * @param string $timezone 1926 | * @param boolean $rollup 1927 | * @param integer $limit 1928 | * @param integer $unitReferenceTimeStamp 1929 | * @return type 1930 | */ 1931 | public function userTrackingDomainClicks($domain, $unit = null, $units = null, $timezone = null, $rollup = null, $limit = null, $unitReferenceTimeStamp = null) 1932 | { 1933 | $params = array('domain' => $domain); 1934 | 1935 | if ($unit !== null) { 1936 | $params['unit'] = $unit; 1937 | } 1938 | 1939 | if ($units !== null) { 1940 | $params['units'] = $units; 1941 | } 1942 | 1943 | if ($timezone !== null) { 1944 | $params['timezone'] = $timezone; 1945 | } 1946 | 1947 | if ($rollup !== null) { 1948 | $params['rollup'] = $rollup; 1949 | } 1950 | 1951 | if ($limit !== null) { 1952 | $params['limit'] = $limit; 1953 | } 1954 | 1955 | if ($unitReferenceTimeStamp !== null) { 1956 | $params['unit_reference_ts'] = $unitReferenceTimeStamp; 1957 | } 1958 | 1959 | return $this->make('user/tracking_domain_clicks', $params); 1960 | } 1961 | 1962 | /** 1963 | * Returns the number of links, pointing to a specified tracking domain, 1964 | * shortened (encoded) in a given time period by all bitly users. 1965 | * Users can register a tracking domain from their bitly settings page. 1966 | * 1967 | * @param string $domain 1968 | * @param string $unit 1969 | * @param integer $units 1970 | * @param string $timezone 1971 | * @param boolean $rollup 1972 | * @param integer $limit 1973 | * @param integer $unitReferenceTimeStamp 1974 | * @return type 1975 | */ 1976 | public function userTrackingDomainShortenCounts($domain, $unit = null, $units = null, $timezone = null, $rollup = null, $limit = null, $unitReferenceTimeStamp = null) 1977 | { 1978 | $params = array('domain' => $domain); 1979 | 1980 | if ($unit !== null) { 1981 | $params['unit'] = $unit; 1982 | } 1983 | 1984 | if ($units !== null) { 1985 | $params['units'] = $units; 1986 | } 1987 | 1988 | if ($timezone !== null) { 1989 | $params['timezone'] = $timezone; 1990 | } 1991 | 1992 | if ($rollup !== null) { 1993 | $params['rollup'] = $rollup; 1994 | } 1995 | 1996 | if ($limit !== null) { 1997 | $params['limit'] = $limit; 1998 | } 1999 | 2000 | if ($unitReferenceTimeStamp !== null) { 2001 | $params['unit_reference_ts'] = $unitReferenceTimeStamp; 2002 | } 2003 | 2004 | return $this->make('user/tracking_domain_shorten_counts', $params); 2005 | } 2006 | 2007 | } 2008 | --------------------------------------------------------------------------------