From 91535365b3a2f0b56f52c982f0e8ab8976d36dc6 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 11 Feb 2011 11:55:23 -0800 Subject: [PATCH] Work in progress: update-profile-data.php to update ostatus profile info from the current feed --- .../OStatus/scripts/update-profile-data.php | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 plugins/OStatus/scripts/update-profile-data.php diff --git a/plugins/OStatus/scripts/update-profile-data.php b/plugins/OStatus/scripts/update-profile-data.php new file mode 100644 index 0000000000..f10da71437 --- /dev/null +++ b/plugins/OStatus/scripts/update-profile-data.php @@ -0,0 +1,88 @@ +#!/usr/bin/env php +. + */ + +define('INSTALLDIR', realpath(dirname(__FILE__) . '/../../..')); + +$helptext = <<isGroup()) { + echo "group\n"; + } else { + $profile = $oprofile->localProfile(); + foreach (array('nickname', 'bio', 'homepage', 'location') as $field) { + print " $field: {$profile->$field}\n"; + } + } + echo "\n"; +} + +echo "Before:\n"; +showProfileInfo($oprofile); + +$feedurl = $oprofile->feeduri; +$client = new HttpClient(); +$response = $client->get($feedurl); +if ($response->isOk()) { + echo "Updating profile from feed: $feedurl\n"; + $dom = new DOMDocument(); + if ($dom->loadXML($response->getBody())) { + $entries = $dom->getElementsByTagNameNS(Activity::ATOM, 'entry'); + if ($entries->length) { + $entry = $entries->item(0); + $activity = new Activity($entry, $feed); + $oprofile->checkAuthorship($activity); + echo " (ok)\n"; + } else { + echo " (no entry; skipping)\n"; + } + } else { + echo " (bad feed; skipping)\n"; + } +} else { + echo "Failed feed fetch: {$response->getStatus()} for $feedurl\n"; +} + +echo "After:\n"; +showProfileInfo($oprofile); -- 2.39.5