Help us understand the problem. What is going on with this article?

gem Koalaをつかってユーザーが特定のページに「いいね!」しているかどうかをチェック

More than 5 years have passed since last update.

https://github.com/arsduo/koala
おなじみ、facebookのgraph APIをrubyでイジイジできるgem
チェックしたいユーザーのaccess_token(もちろんパーミッションで「いいね!」を取ってこれるようにしておかないとダメですが)があればOK
https://developers.facebook.com/tools/explorer
Graph APIエクスプローラーでとりあえず試せるので、「アクセストークンを取得」→「User Data Permissions」タブ「user_likes」にチェックが入っていることを確認し「Get Access Token」
アクセストークンをコピーしておく。

fb_like_or_not.rb
require "Koala"
client = Koala::Facebook::API.new(access_token)

#URL先を「いいね!」しているかそうでないかをチェック

url = "http://www.livlis.com/"
client.fql_query("SELECT url FROM url_like WHERE user_id=me()").map do |like|
  like["url"]
end.include?(url) #=> true

#おまけ。「いいね!」している数のチェック
client.fql_query("SELECT like_count FROM link_stat WHERE url=\"#{url}\"").first["like_count"] #=> 285
ubiregi
iPadを活用したSaaS型POSシステム「Ubiregi (ユビレジ)」を開発・提供しています
https://ubiregi.com
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした