#!/usr/bin/env bash
BASE="https://casacourses.com"
TOKEN="APP_ID|APP_SECRET"
# Pull last 15 updated node URLs of target types via Views JSON, or Drush:
# Example using Drush (adjust to your setup):
for nid in $(drush sqlq "SELECT n.nid FROM node n WHERE n.status=1 AND n.type IN ('resultat','analyse_des_courses','rapports_cpc') ORDER BY n.changed DESC LIMIT 15;" -r /home/ccwadmin/public_html | tail -n +2); do
URL="$(drush uli --pipe --no-browser --uid=1 --r=/home/ccwadmin/public_html | sed 's/\?.*$//')node/${nid}"
# If you have path aliases, get alias:
ALIAS=$(drush php-eval "echo drupal_get_path_alias('node/${nid}');" -r /home/ccwadmin/public_html)
[ -n "$ALIAS" ] && URL="${BASE}/${ALIAS}"
# version bump with changed ts
CHANGED=$(drush sqlq "SELECT changed FROM node WHERE nid=${nid};" -r /home/ccwadmin/public_html | tail -n1)
[ -n "$CHANGED" ] && URL="${URL}?v=${CHANGED}"
curl -s -X POST "https://graph.facebook.com/?id=${URL}&scrape=true&access_token=${TOKEN}" >/dev/null
done