go client for mashable
Mashable was created by Pete Cashmore
in July 2005. Time noted Mashable as one of the 25
best blogs in 2009, and has been described as one stop shop
for social media.
As of November 2015, it has over 6,000,000 Twitter followers and over 3,200,000 fans on Facebook.
While working on a research paper about data mining with one of my friend, i needed to parse a lot (i really mean a lot) of mashable data as my test dataset, to extract the data i desires. I was trying to write a web parser first, while i discovered the mashable api as far they have and saves me lots of time. Instead of making a web parser i then write the api clients for mashable.
The api is undocumented, so the exact formats or some api endpoints can be missed. In case of scenario like, i will be happy to get suggestions or PRs.
The supported resource list by the client is follows
- Post
- List
- Get
- Get From Url
- Comments
- Topics
- List
- Get
- User
- Get
- Search
- Search with Query
If more api resources are found, will be added here.
$ go get -u github.com/sadlil/mashable
Create Client:
import (
"github.com/sadlil/mashable"
)
func main() {
c, err := mashable.New()
if err != nil {
panic("client creation failed")
}
}
Get Posts:
// List returns the list of post order by post time. `ListOptions` contains two configurable
// field `page` and `per_page`. Setting `page` will return the specified page of the list. according
// `per_page`. Default values is 1 for the page and 20 for the per_page.
posts, err := c.Posts().List(&mashable.ListOptions{})
// Get a specified post by its id
post, err := c.Posts().Get(id)
// Get a specified post by its blog url. usefull if you do not know the id
post, err := c.Posts().GetFromUrl(url)
Get Topics:
// List returns the list of topic. `ListOptions` contains two configurable
// field `page` and `per_page`. Setting `page` will return the specified page of the list. according
// `per_page`. Default values is 1 for the page and 20 for the per_page.
topics, err := c.Topics().List(&mashable.ListOptions{})
// Get a specified topic by its slug
topic, err := c.Topics().Get(slug)
Get User:
// Get a specified user by his/her id
user, err := c.Users().Get(id)
Search:
// Get search result according to a search query
res, err := c.Search().Query(query)
Details of all the response types can be found in types.go file. Check tests for more examples.
Licensed under the MIT license. See the LICENSE file for details.