Skip to content

Instantly share code, notes, and snippets.

@ashleymason
Last active February 18, 2019 16:31
Show Gist options
  • Select an option

  • Save ashleymason/d6fda728fe28dce1a82a9347314a492d to your computer and use it in GitHub Desktop.

Select an option

Save ashleymason/d6fda728fe28dce1a82a9347314a492d to your computer and use it in GitHub Desktop.
Adding Facebook likes and comments to an Ad

To add Facebook comments and likes to the ad

Purchase a campaign and make it live, then:

rake webhook:facebook:comment:add[5,4]

where 5 is the FacebookAdCreative with id 5 and 4 is the number of comments.

if you would like to add likes

rake webhook:facebook:like:add[5,4]

You should see output Status: 200

To get the email to send for the likes and comments

Facebook::PageFeedUpdateNotifier.new.perform(<facebook_creative_id>,:notify_comments)
Facebook::PageFeedUpdateNotifier.new.perform(<facebook_creative_id>,:notify_likes)

or

Facebook::PageFeedUpdateMailer.notify_comments(Facebook::Comment.all).deliver_now
Facebook::PageFeedUpdateMailer.notify_likes(Facebook::Like.all).deliver_now
Facebook::PageFeedUpdateMailer.daily_digest()

You might get an error about a from address, in which case you can run, for instance:

Facebook::PageFeedUpdateMailer.notify_comments(Facebook::Comment.all, from: 'sdash@adwerx.com').deliver_now

Run the worker to put the data in the database

{
  "field"=>"feed",
  "value"=>{
    "item"=>"comment",
    "verb"=>"add",
    "comment_id"=>"1457371147_4",
    "post_id"=>"1603988749878111_1700966186847033",
    "parent_id"=>"1603988749878111_1700966186847033",
    "sender_id"=>100008601228732,
    "created_time"=>1457371147,
    "message"=>"qi😱ht😱 lmi😱punay a😱Co",
    "sender_name"=>"Jösh Bārds"
  }
},
"1603988749878111",
1457371147
  • open a rails console and run Workers::Facebook::IngestPageFeedUpdate.new.perform() You should now have that like/comment attached to your Facebook ad creative.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment