3 require_once('include/Scrape.php');
4 require_once('include/follow.php');
6 function ostatus_subscribe_content(App &$a) {
9 notice( t('Permission denied.') . EOL);
10 goaway($_SESSION['return_url']);
14 $o = "<h2>".t("Subscribing to OStatus contacts")."</h2>";
20 $counter = intval($_REQUEST['counter']);
22 if (get_pconfig($uid, "ostatus", "legacy_friends") == "") {
24 if ($_REQUEST["url"] == "") {
25 return $o.t("No contact provided.");
28 $contact = probe_url($_REQUEST["url"]);
31 return $o.t("Couldn't fetch information for contact.");
34 $api = $contact["baseurl"]."/api/";
37 $data = z_fetch_url($api."statuses/friends.json?screen_name=".$contact["nick"]);
39 if (!$data["success"]) {
40 return $o.t("Couldn't fetch friends for contact.");
43 set_pconfig($uid, "ostatus", "legacy_friends", $data["body"]);
46 $friends = json_decode(get_pconfig($uid, "ostatus", "legacy_friends"));
48 $total = sizeof($friends);
50 if ($counter >= $total) {
51 $a->page['htmlhead'] = '<meta http-equiv="refresh" content="0; URL='.App::get_baseurl().'/settings/connectors">';
52 del_pconfig($uid, "ostatus", "legacy_friends");
53 del_pconfig($uid, "ostatus", "legacy_contact");
58 $friend = $friends[$counter++];
60 $url = $friend->statusnet_profile_url;
62 $o .= "<p>".$counter."/".$total.": ".$url;
64 $data = probe_url($url);
65 if ($data["network"] == NETWORK_OSTATUS) {
66 $result = new_contact($uid,$url,true);
67 if ($result["success"]) {
68 $o .= " - ".t("success");
70 $o .= " - ".t("failed");
73 $o .= " - ".t("ignored");
78 $o .= "<p>".t("Keep this window open until done.")."</p>";
80 $a->page['htmlhead'] = '<meta http-equiv="refresh" content="0; URL='.App::get_baseurl().'/ostatus_subscribe?counter='.$counter.'">';