5 require_once 'include/probe.php';
6 require_once 'include/follow.php';
8 function ostatus_subscribe_content(App $a) {
11 notice( t('Permission denied.') . EOL);
12 goaway($_SESSION['return_url']);
16 $o = "<h2>".t("Subscribing to OStatus contacts")."</h2>";
22 $counter = intval($_REQUEST['counter']);
24 if (get_pconfig($uid, "ostatus", "legacy_friends") == "") {
26 if ($_REQUEST["url"] == "") {
27 return $o.t("No contact provided.");
30 $contact = probe_url($_REQUEST["url"]);
33 return $o.t("Couldn't fetch information for contact.");
36 $api = $contact["baseurl"]."/api/";
39 $data = z_fetch_url($api."statuses/friends.json?screen_name=".$contact["nick"]);
41 if (!$data["success"]) {
42 return $o.t("Couldn't fetch friends for contact.");
45 set_pconfig($uid, "ostatus", "legacy_friends", $data["body"]);
48 $friends = json_decode(get_pconfig($uid, "ostatus", "legacy_friends"));
50 $total = sizeof($friends);
52 if ($counter >= $total) {
53 $a->page['htmlhead'] = '<meta http-equiv="refresh" content="0; URL='.App::get_baseurl().'/settings/connectors">';
54 del_pconfig($uid, "ostatus", "legacy_friends");
55 del_pconfig($uid, "ostatus", "legacy_contact");
60 $friend = $friends[$counter++];
62 $url = $friend->statusnet_profile_url;
64 $o .= "<p>".$counter."/".$total.": ".$url;
66 $data = probe_url($url);
67 if ($data["network"] == NETWORK_OSTATUS) {
68 $result = new_contact($uid,$url,true);
69 if ($result["success"]) {
70 $o .= " - ".t("success");
72 $o .= " - ".t("failed");
75 $o .= " - ".t("ignored");
80 $o .= "<p>".t("Keep this window open until done.")."</p>";
82 $a->page['htmlhead'] = '<meta http-equiv="refresh" content="0; URL='.App::get_baseurl().'/ostatus_subscribe?counter='.$counter.'">';