Permalink
Browse files

White-space and docblock updates.

  • Loading branch information...
1 parent f37073b commit e40d98ec8e5f7a263cbb8defa145c1c57d95956d @ckieffer ckieffer committed Feb 12, 2011
Showing with 8 additions and 12 deletions.
  1. +0 −1 3.1/modules/bitly/controllers/bitly.php
  2. +8 −11 3.1/modules/bitly/helpers/bitly.php
@@ -39,7 +39,6 @@ public function shorten($item_id) {
if ($short_url) {
message::success("Item URL shortened to $short_url");
} else {
-
message::error("Unable to shorten " . url::abs_site($item->relative_url_cache));
}
@@ -61,8 +61,8 @@ static function get_configure_form() {
/**
* Check a login and an API Key against bit.ly to make sure they're valid
- * @param string $login the login
- * @param string $api_key the API key
+ * @param string $login bit.ly login
+ * @param string $api_key bit.ly API key
* @return boolean
*/
static function validate_config($login, $api_key) {
@@ -115,15 +115,15 @@ static function check_config() {
}
/**
- *
- * @param <type> $type
- * @param <type> $parameters
+ * Assemble a bitly API request
+ * @param string $type Type of API request, ex. shorten
+ * @param array $params Query string key/value pairs
* @return string
*/
- private static function _build_http_request($type, $parameters) {
+ private static function _build_http_request($type, $params) {
$http_request = '';
- if (!empty($type) && count($parameters)) {
- foreach($parameters as $k => $v) {
+ if (!empty($type) && count($params)) {
+ foreach($params as $k => $v) {
$query_string[] = "$k=" . urlencode($v);
}
$path = "/" . self::$api_version . "/$type?" . implode('&', $query_string);
@@ -175,15 +175,13 @@ static function shorten_url($item_id, $format='json') {
$item = ORM::factory("item", $item_id);
$short_url = '';
$long_url = url::abs_site($item->relative_url_cache);
-
$parameters = array(
"login" => module::get_var("bitly", "login"),
'apiKey' => module::get_var("bitly", "api_key"),
'longUrl' => $long_url,
'domain' => module::get_var("bitly", "domain"),
'format' => $format,
);
-
$request = self::_build_http_request('shorten', $parameters);
$response = self::_http_post($request, self::$api_host);
$json_response = json_decode($response->body[0]);
@@ -198,7 +196,6 @@ static function shorten_url($item_id, $format='json') {
$link->global_hash = $json_response->data->global_hash;
$link->save();
return $json_response->data->url;
-
} else {
$status_code = $json_response->status_code;
log::error("content", "Shortened URL", "Error: $status_code $status_txt <a href=\"{$long_url}\">item</a>");

0 comments on commit e40d98e

Please sign in to comment.