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);