From: Brion Vibber Date: Fri, 11 Feb 2011 19:55:23 +0000 (-0800) Subject: Work in progress: update-profile-data.php to update ostatus profile info from the... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=91535365b3a2f0b56f52c982f0e8ab8976d36dc6;p=quix0rs-gnu-social.git Work in progress: update-profile-data.php to update ostatus profile info from the current feed --- 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);