Skip to content
This repository has been archived by the owner on Apr 5, 2020. It is now read-only.

Commit

Permalink
Remove API endpoint shortcut methods
Browse files Browse the repository at this point in the history
This drastically simplifies the class, and allows for future changes to the API without having to alter and re-test all the shortcut methods. `Topsy::get()` should be used in all cases.
  • Loading branch information
rowanmanning committed Aug 23, 2011
1 parent 39a2336 commit 94b683a
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 185 deletions.
11 changes: 0 additions & 11 deletions README.md
Expand Up @@ -28,17 +28,6 @@ $topsy->get('trackbacks', array(
?> ?>
``` ```


Most API endpoints have shortcut methods too.

```php
<?php

// we can simplify the above example like this
$topsy->trackbacks('http://github.com/');

?>
```

--- ---


Copyright 2011, Rowan Manning Copyright 2011, Rowan Manning
Expand Down
174 changes: 0 additions & 174 deletions lib/Topsy.php
Expand Up @@ -279,180 +279,6 @@ public function get($endpoint, $params = null) {
} }


//------------------------------------------------------------ //------------------------------------------------------------
// API ENDPOINT SHORTCUT FUNCTIONS
//------------------------------------------------------------

/**
* Get profile information for an author.
*
* See http://code.google.com/p/otterapi/wiki/Resources#/authorinfo for more information.
*
* @param string $author_url URL string for the author.
* @param array $params An array of additional parameters to send with the request. Default value is `null`.
* @return array Returns an array of response data.
*/
public function authorinfo($author_url, $params = null) {

$params['url'] = $author_url;
return $this->get('authorinfo', $params);

}

/**
* Get a list of authors who talk about a query.
*
* See http://code.google.com/p/otterapi/wiki/Resources#/experts for more information.
*
* @param string $query Search query string. See http://code.google.com/p/otterapi/wiki/QuerySyntax for syntax.
* @param array $params An array of additional parameters to send with the request. Default value is `null`.
* @return array Returns an array of response data.
*/
public function experts($query, $params = null) {

$params['q'] = $query;
return $this->get('experts', $params);

}

/**
* Get a list of URLs posted by an author.
*
* See http://code.google.com/p/otterapi/wiki/Resources#/linkposts for more information.
*
* @param string $author_url URL string for the author.
* @param string $contains Filter query string. See http://code.google.com/p/otterapi/wiki/QuerySyntax for syntax. Default value is `null`.
* @param string $tracktype The type of post to retrieve. Options include: 'image', 'tweet__various' (tweets and retweets) and 'self__tweet' (tweets by user). Default value is `null`.
* @param array $params An array of additional parameters to send with the request. Default value is `null`.
* @return array Returns an array of response data.
*/
public function linkposts($author_url, $contains = null, $tracktype = null, $params = null) {

$params['url'] = $author_url;
if ($contains !== null) {
$params['contains'] = $contains;
}
if ($tracktype !== null) {
$params['tracktype'] = $tracktype;
}
return $this->get('linkposts', $params);

}

/**
* Get a count of URLs posted by an author.
*
* See http://code.google.com/p/otterapi/wiki/Resources#/linkpostcount for more information.
*
* @param string $author_url URL string for the author.
* @param string $contains Filter query string. See http://code.google.com/p/otterapi/wiki/QuerySyntax for syntax. Default value is `null`.
* @param string $tracktype The type of post to retrieve. Options include: 'image', 'tweet__various' (tweets and retweets) and 'self__tweet' (tweets by user). Default value is `null`.
* @param array $params An array of additional parameters to send with the request. Default value is `null`.
* @return array Returns an array of response data.
*/
public function linkpostcount($author_url, $contains = null, $tracktype = null, $params = null) {

$params['url'] = $author_url;
if ($contains !== null) {
$params['contains'] = $contains;
}
if ($tracktype !== null) {
$params['tracktype'] = $tracktype;
}
return $this->get('linkpostcount', $params);

}

/**
* Get a list of the most popular and unique tweets (trackbacks) that mention the query URL.
*
* See http://code.google.com/p/otterapi/wiki/Resources#/populartrackbacks for more information.
*
* @param string $url URL string for the target.
* @param array $params An array of additional parameters to send with the request. Default value is `null`.
* @return array Returns an array of response data.
*/
public function populartrackbacks($url, $params = null) {

$params['url'] = $url;
return $this->get('populartrackbacks', $params);

}

/**
* Get a list of related URLs.
*
* See http://code.google.com/p/otterapi/wiki/Resources#/related for more information.
*
* @param string $url URL string for the target.
* @param array $params An array of additional parameters to send with the request. Default value is `null`.
* @return array Returns an array of response data.
*/
public function related($url, $params = null) {

$params['url'] = $url;
return $this->get('related', $params);

}

/**
* Get a list of results matching a query.
*
* See http://code.google.com/p/otterapi/wiki/Resources#/search for more information.
*
* @param string $query Search query string. See http://code.google.com/p/otterapi/wiki/QuerySyntax for syntax.
* @param string $window Time window for the results. See http://code.google.com/p/otterapi/wiki/Resources#/search for detail. Default value is `null`.
* @param string $type The type of result to return. Supported types are 'image', 'tweet' and 'video'. Default value is `null` (all types).
* @param string $query_features Enables QueryFeatures. See http://code.google.com/p/otterapi/wiki/QueryFeatures. Default value is `null`.
* @param array $params An array of additional parameters to send with the request. Default value is `null`.
* @return array Returns an array of response data.
*/
public function search($query, $window = null, $type = null, $query_features = null, $params = null) {

$params['q'] = $query;
if ($window !== null) {
$params['window'] = $window;
}
if ($type !== null) {
$params['type'] = $type;
}
if ($query_features !== null) {
$params['query_features'] = $query_features;
}
return $this->get('search', $params);

}

/**
* Get a count of results matching a query.
*
* See http://code.google.com/p/otterapi/wiki/Resources#/searchcount for more information.
*
* @param string $query Search query string. See http://code.google.com/p/otterapi/wiki/QuerySyntax for syntax.
* @param string $dynamic Whether to choose the best window for this query. Default value is `null`.
* @param array $params An array of additional parameters to send with the request. Default value is `null`.
* @return array Returns an array of response data.
*/
public function searchcount($query, $dynamic = null, $params = null) {

$params['q'] = $query;
if ($dynamic !== null) {
$params['dynamic'] = $dynamic;
}
return $this->get('searchcount', $params);

}

// TODO
public function searchhistogram() {}
public function searchdate() {}
public function stats() {}
public function top() {}
public function tags() {}
public function trackbacks() {}
public function trending() {}
public function urlinfo() {}

//------------------------------------------------------------


} }


Expand Down

0 comments on commit 94b683a

Please sign in to comment.