• Posts
  • RSS
  • ◂◂RSS
  • Contact

  • Reworking Facebook Comment Inclusion

    April 26th, 2018
    comments, tech  [html]
    I've included Facebook comments on my posts here since 2011, as a way to make it easier for people to follow the discussion without using Facebook. I initially implemented this via a Facebook app running as me. This worked fine, until Facebook's recent app restrictions in response to Cambridge Analytica.

    The information I'm trying to include here, however, is fully public: if you follow a link to an example Facebook crosspost while not logged into Facebook you can still read the comments. So I've switched from using the API, with its privleges to read anything I can read, to just scraping the public-facing page.

    This has two components:

    • Make a request in a javascript-running browser in order to get the temporary tokens I need to FB to allow my request. I tried to use Selenium for this, but the tiny VPS I host this blog on has too little memory to run a browser. So I use the WebPageTest API instead. I have this set to run automatically each night, getting a single request, via this python script as a cron job.

    • When trying to load comments, use those saved tokens to make the same kind of AJAX request Facebook's front end makes. This happens in response to a user viewing a post with comments, and is in this script.

    Neither of these are examples of especially good code, and are instead examples of just staying up late poking the tools until they do what I want.

    (This is how my Google Plus integration has worked from the beginning, except that it doesn't require any tokens and so only needs the second stage.)

    Comment via: google plus, facebook

    Recent posts on blogs I like:

    Fireside Friday: January 1, 2021

    Happy New Year! Good riddance 2020! Fireside this week. Next week, we’ll be finishing up our look at the Dothraki of A Song of Ice and Fire and Game of Thrones by looking at how they are shown to fight and comparing that to the fighting patterns of actual…

    via A Collection of Unmitigated Pedantry January 1, 2021

    Streets Before Trust

    There’s an emerging mentality among left-wing urban planners in the US called “trust before streets.” It’s a terrible idea that should disappear, a culmination of about 50 or 60 years of learned helplessness in the American public sector. Too many people …

    via Pedestrian Observations January 1, 2021

    Systems design explains the world: volume 1

    "Systems design" is a branch of study that tries to find universal architectural patterns that are valid across disciplines. You might think that's not a possibility. Back in university, students used to tease the Systems Design Engineers, ca…

    via apenwarr December 29, 2020

    more     (via openring)


  • Posts
  • RSS
  • ◂◂RSS
  • Contact