Facebook ads diet

I got tired of Facebook ads in the News feed so checked the Ad preferences that they provide and turned off a bunch of tracking options. There’s a lot of tracking going on (see below) and that’s only the “public” data they share with the user.

My most hated ad is when some friend liked some ad and they show it to me. That’s kinda stuff I’m really not interested in and finally found the switch to turn that off.

Facebook ad preferences
Facebook ad preferences

Get Facebook Page likes count via PHP with access_token

Today I had to figure out how to fetch again Facebook Page likes via PHP. Friends from FB changed the API and it was now saying An access token is required to request this resource. for the old API call. Accessing the data requires access_token from now on. Reading the docs https://developers.facebook.com/docs/graph-api/reference/page#Reading I found that a page access token exists.

How to get that page access token?

First you gonna need your FB id, visit https://developers.facebook.com/tools/explorer?method=GET&path=me& (should be the first id) Next you need to grab via API call /YOUR_FB_ID/accounts https://developers.facebook.com/tools/explorer?method=GET&path=YOUR_FB_ID%2Faccounts& After this magic should happen and you should see access_tokens for pages you manage. Now with the access token you can get data via the following URL https://graph.facebook.com/v2.3/FB_PAGE_ID?access_token=PAGE_ACCESS_TOKEN The output is a json which you can decode with PHP function json_decode().

I’ve got the following message: Error validating access token: Session has expired on Saturday, 20-Jun-15 00:00:00 PDT.
Token expired :/ You can check yours at https://developers.facebook.com/tools/debug/accesstoken?q=
I made a never expiring page access token thanks to https://www.rocketmarketinginc.com/blog/get-never-expiring-facebook-page-access-token/

FB neves expiring page access token

Facebook group posts on own webpage in PHP

A friend needed his FB groups posts embedded on his webpage so here are some snippets that I don’t forget 😀

  1. At https://developers.facebook.com create a new APP, after creating you get the required ID and SECRET.
  2. From https://github.com/facebook/facebook-php-sdk download the PHP SDK

require_once(WB_PATH."/include/facebook/src/facebook.php"); // Get from https://github.com/facebook/facebook-php-sdk


$config = array(
'appId' => $APP_ID,
'secret' => $APP_SECRET,
'fileUpload' => false,
'allowSignedRequest' => false,

$facebook = new Facebook($config);

$posts = '';
foreach ($data as $d) {
if (!empty($d['message'])) {
$posts .= '

  • '.date('d.m.Y H:i', strtotime($d['created_time'])).'


  • ';

    During googling I found http://pastebin.com/LPnzUQSF, but I didn’t try.

    Získanie zoznamu Facebook Likerov

    Po dlhšom googlení som nenašiel riešenie ako získať zoznam ľudí, ktorí dali Like Facebook stránke, tak som sa vrhol do toho sám a množstvom pokusov a omylov som sa dopracoval k zoznamu nasledovne. Do Chromu som potreboval pridať extension menom jQuerify, ktorá za mňa porieši vsunutie jQuery knižnice do FB stránky. Ako admin FB stránky našej firemnej stránky http://www.facebook.com/nevillegroup som klikol na odkaz, ktorý vylistuje likerov.

    Treba kliknúť na ikonu jQuerify, aby sa jQuery knižnica vsunula do stránky.

    Ďalej, keď už máme dialogové okno s likermi, treba otvoriť Chrome Developer Tools a prepnúť sa do konzoly.

    Nasledovný príkaz vylistuje odkazy na profilové stránky užívateľov:


    V prípade, že chcete len mená, tak použite nasledovný príkaz:


    Po spustení sa zobrazí zoznam odkazov, ktoré už pomocou vyznačenim a Ctrl+c je možné skopírovať.