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.");
27 $contact = probe_url($_REQUEST["url"]);
30 return $o.t("Couldn't fetch information for contact.");
32 $api = $contact["baseurl"]."/api/";
35 $data = z_fetch_url($api."statuses/friends.json?screen_name=".$contact["nick"]);
37 if (!$data["success"])
38 return $o.t("Couldn't fetch friends for contact.");
40 set_pconfig($uid, "ostatus", "legacy_friends", $data["body"]);
43 $friends = json_decode(get_pconfig($uid, "ostatus", "legacy_friends"));
45 $total = sizeof($friends);
47 if ($counter >= $total) {
48 $a->page['htmlhead'] = '<meta http-equiv="refresh" content="0; URL='.App::get_baseurl().'/settings/connectors">';
49 del_pconfig($uid, "ostatus", "legacy_friends");
50 del_pconfig($uid, "ostatus", "legacy_contact");
55 $friend = $friends[$counter++];
57 $url = $friend->statusnet_profile_url;
59 $o .= "<p>".$counter."/".$total.": ".$url;
61 $data = probe_url($url);
62 if ($data["network"] == NETWORK_OSTATUS) {
63 $result = new_contact($uid,$url,true);
64 if ($result["success"])
65 $o .= " - ".t("success");
67 $o .= " - ".t("failed");
69 $o .= " - ".t("ignored");
73 $o .= "<p>".t("Keep this window open until done.")."</p>";
75 $a->page['htmlhead'] = '<meta http-equiv="refresh" content="0; URL='.App::get_baseurl().'/ostatus_subscribe?counter='.$counter.'">';