Skip to content

Achievements and Scores

nov matake edited this page Dec 16, 2011 · 2 revisions

Achievements and Scores

Achievements

In Application Context

achievement_url = 'http://fbgraphsample.heroku.com/achievements/1'
app = FbGraph::Application.new(APP_ID, :secret => APP_SECRET)

# Register Achievement
app.achievement! achievement_url

# Fetch Registered Achievements
achievements = app.achievements

# Unregister Achievement
achievements.first.destroy

In User Context

app = FbGraph::Application.new(APP_ID, :secret => APP_SECRET)
user = FbGraph::User.new('matake', :access_token => ACCESS_TOKEN)

# Give Achievement
achievement = user.achieve! achievement_url, :access_token => app.access_token

# Fetch Given Achievements
achievements = user.achievements

# Delete Achievement
achievements.first.destroy :access_token => app.access_token

Scores

app = FbGraph::Application.new(APP_ID, :secret => APP_SECRET)
user = FbGraph::User.new('matake', :access_token => ACCESS_TOKEN)

# Get scores
user.scores

# Update (or register) score
matake.score! 10, :access_token => app.access_token

# Clear score
matake.unscore! :access_token => app.access_token
Clone this wiki locally