This extensions allows you to perform REST callbacks to the {@link bit.ly} service and perform several operations such as:
This extensions allows you to perform REST callbacks to the {@link bit.ly} service and perform several operations such as:
Each operation has it's own method listed below. You can refer to the method description to see a full description of it's usage, examples and the output example, as well as see all the available parameters you can pass to each method.
This class also supports caching, So if you perform a callback it will cache the result to reduce the number of calls the extensions needs to perform. It will cache the data based on all postParams, format and callback type, So no conflicts and duplicated values will be saved/retrieved.
protected/extensionsIn order to activate the extension and use it's methods you will need to add the following component code to your application configuration.
'bitly' => array( 'class' => 'application.extensions.bitly.VGBitly', 'login' => 'xxxxx', // login name 'apiKey' => 'xxxxxx', // apikey 'format' => 'xml', // default format of the response this can be either xml, json (some callbacks support txt as well) ),
You can also pass specify parameters such as:
Yii::app()->bitly->shorten('http://www.betaworks.com')->getResponseData();
Array ( [status_code] => 200 [status_txt] => OK [data] => Array ( [url] => http://bit.ly/9PCy42 [hash] => 9PCy42 [global_hash] => 25iRBL [long_url] => http://www.betaworks.com [new_hash] => 0 ) )
Yii::app()->bitly->expand('http://bit.ly/1RmnUT')->getResponseData();
Array ( [status_code] => 200 [status_txt] => OK [data] => Array ( [entry] => Array ( [short_url] => http://bit.ly/1RmnUT [long_url] => http://google.com [user_hash] => 1RmnUT [global_hash] => 1RmnUT ) ) )
Yii::app()->bitly->validate('loginName', 'APIKEY')->getResponseData();
Array ( [status_code] => 200 [status_txt] => OK [data] => Array ( [valid] => 1 ) )
Yii::app()->bitly->clicks('http://bit.ly/1RmnUT')->getResponseData();
Array ( [status_code] => 200 [data] => Array ( [clicks] => Array ( [short_url] => http://bit.ly/1RmnUT [global_hash] => 1RmnUT [user_clicks] => 3508 [user_hash] => 1RmnUT [global_clicks] => 3508 ) ) [status_txt] => OK )
Yii::app()->bitly->bitly_pro_domain('nyti.ms')->getResponseData();
Array ( [status_code] => 200 [data] => Array ( [domain] => nyti.ms [bitly_pro_domain] => 1 ) [status_txt] => OK )
Total 1 comment
Nice work man. Very easy to use.
Leave a comment
Please login to leave your comment.