Skip to content
Henry Smith edited this page Sep 4, 2011 · 13 revisions

Reference

Methods that require a valid login

vote($direction)

Casts a vote on the link. 1 for an upvote, -1 for a downvote, 0 to remove a vote.

comment($text)

Posts a comment in reply to the link.

save()

Saves the link.

unsave()

Unsaves the link

hide()

Hides the link

unhide()

Unhides the link

Methods that don't require a valid login but only return meaningful data if logged-in

These methods won't throw an exception if called when not logged in, but there's not much point in doing so since they won't tell you anything useful.

isClicked()

Indicates whether the logged-in user has clicked on the link.

isHidden()

Indicates whether the logged-in user has hidden the link.

isSaved()

Indicates whether the logged-in user has saved the link.

Methods that do not require a login

getComments()

Returns an array of the comments posted in reply to the link Only direct replies to the link itself are in the array. Replies to those comments are stored in the comments themselves.

If the link was fetched without comments, comments are fetched from the API. Avoid this scenario where possible, the API documentation specifically asks for users to pull in information in bulk rather than in lots of different requests.

getThingId()

Returns the link's unique 't3_*' ID

getId()

Returns the link's ID

getUpvotes()

Returns the number of upvotes given to the link

getDownvotes()

Returns the number of downvotes given to the link

getScore()

Returns the link's score Score is a function of upvotes, downvotes, and time since creation

countComments()

Returns the number of replies to the link

getAuthorName()

Returns the username of the user who submitted the link

getTitle()

Returns the title of the link

getUrl()

Returns the URL that the post is a link

getPermaLink($absolute = false)

Returns the permalink to the link on Reddit. If $absolute is true, returns the full absolute URL. If not, returns just the path.

getSelfText()

If the link is a self-post, this method returns the self text

isSelfPost()

Indicates whether the post is a self-post or a link

isAgeRestricted()

Indicates whether the post is restricted to those 18-years-old or over