Exemplo n.º 1
0
function test_friendfeed()
{
    header("Content-Type: text/plain");
    // Fill in a nickname and a valid remote key below for authenticated
    // actions like posting an entry and reading a protected feed
    // $session = new FriendFeed($_POST["nickname"], $_POST["remote_key"]);
    $session = new FriendFeed();
    $feed = $session->fetch_public_feed();
    // $feed = $session->fetch_user_feed("bret");
    // $feed = $session->fetch_user_feed("paul", "twitter");
    // $feed = $session->fetch_user_discussion_feed("bret");
    // $feed = $session->fetch_multi_user_feed(array("bret", "paul", "jim"));
    // $feed = $session->search("who:bret friendfeed");
    foreach ($feed->entries as $entry) {
        print $entry->title . "\n";
    }
    if ($session->auth_nickname && $session->auth_key) {
        // The feed that the authenticated user would see on their home page
        $feed = $session->fetch_home_feed();
        // Post a message on this user's feed
        $entry = $session->publish_message("Testing the FriendFeed API");
        print "Posted new message at http://friendfeed.com/e/" . $entry->id . "\n";
        // Post a link on this user's feed
        $entry = $session->publish_link("Testing the FriendFeed API", "http://friendfeed.com/");
        print "Posted new link at http://friendfeed.com/e/" . $entry->id . "\n";
        // Post a link with two thumbnails on this user's feed
        $entry = $session->publish_link("Testing the FriendFeed API", "http://friendfeed.com/", "Test comment on this test entry", array("http://friendfeed.com/static/images/jim-superman.jpg", "http://friendfeed.com/static/images/logo.png"));
        print "Posted images at http://friendfeed.com/e/" . $entry->id . "\n";
    }
}
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>FF Subscription Exporter</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
</head>
<html>
<body>
<p>In order to save this you must use your browser's, "Save As" function.</p>
<br />
<?php 
require_once "php/ffriendfeed.php";
require_once "php/JSON.php";
$user = $_POST['username'];
$key = $_POST['remotekey'];
$length = $_POST['subscriptions'];
$session = new FriendFeed($user, $key);
do {
    //Creates a session to access users Subscriptions
    $feed = $session->fetch_user_profile($user, null, $length - 100, $length);
    foreach ($feed->subscriptions as $sub) {
        $subscriptions = null;
        $username = $sub->nickname;
        //Accesses your Subscriptions info to extract services
        $profiles = $session->fetch_user_profile($username, null, 0, 30);
        //Super Sloppy Validation  prevents private feeds from displaying if RemoteKey was left blank.
        if ($profiles->status == 'public' || $key != null) {
            print $username . " --  ";
            //Next line originally existed on line 32 and causes a foreach() error on occasion at http://hiphs.com/ff/friends
            foreach ($profiles->services as $service) {
                $subServices = null;
                $subServices .= '<img src="' . $service->iconUrl . '" alt="' . $service->name . '" />';
 /**
  * Load the discussions from the FriendFeed API
  *
  * @return void
  */
 function update_friendfeedcomments()
 {
     $options = get_option($this->options_key);
     $friendfeed = new FriendFeed($options['nickname']);
     if ($options && $friendfeed) {
         if ($this->is_debug()) {
             $this->printr("Loading FriendFeed Data");
         }
         $ff_entries = $friendfeed->fetch_user_feed($options['nickname'], $options['servicename']);
         if ($ff_entries && is_array($ff_entries->entries)) {
             //Load up the posts from FriendFeed up to the max number of posts to load set
             for ($i = $this->page_size; $i <= $this->max_posts_to_load - $this->page_size; $i = $i + $this->page_size) {
                 $temp_posts = $friendfeed->fetch_user_feed($options['nickname'], $options['servicename'], $i, $this->page_size);
                 if ($temp_posts && is_array($temp_posts->entries)) {
                     $ff_entries->entries = array_merge($ff_entries->entries, $temp_posts->entries);
                 } else {
                     $i = $this->max_posts_to_load;
                 }
             }
             $blog_url = parse_url(strtolower(get_option('home')));
             $match_count = 0;
             $titles = get_option($this->titles_key);
             if (!is_array($titles)) {
                 $titles = array();
             }
             foreach ($ff_entries->entries as $entry) {
                 $post_url = parse_url(strtolower($entry->service->profileUrl));
                 $is_same_blog = ($blog_url['host'] == $post_url['host'] || $blog_url['host'] == 'www.' . $post_url['host'] || 'www.' . $blog_url['host'] == $post_url['host']) && ($post_url['path'] == $blog_url['path'] . '/' || $post_url['path'] . '/' == $blog_url['path'] || $post_url['path'] == $blog_url['path']);
                 if ($is_same_blog) {
                     if ($titles[$entry->id]) {
                         $this->update_entry($entry->id, $entry->comments, $entry->likes);
                     } else {
                         $this->add_entry($entry->id, $entry->title, $entry->comments, $entry->likes);
                         $titles[$entry->id] = $entry->title;
                     }
                     $match_count++;
                 }
             }
             update_option($this->titles_key, $titles);
             if ($this->is_debug()) {
                 $this->printr(count($ff_entries->entries) . " entries loaded from FriendFeed");
                 $this->printr("{$match_count} entries loaded, " . count($titles) . " total entries stored.");
                 $this->printr('** Discussions **');
                 $this->printr($titles);
                 $this->printr('** Posts **');
                 $this->printr($ff_entries);
             }
         } else {
             return false;
         }
     }
     return true;
 }
Exemplo n.º 4
0
<?php

require_once "friendfeed.php";
$uploaded = false;
$entry = null;
if ($_POST["title"]) {
    $uploaded = true;
    $friendfeed = new FriendFeed($_POST["nickname"], $_POST["remotekey"]);
    $entry = $friendfeed->publish_link($_POST["title"], $_POST["link"]);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>FriendFeed Remote Login Form</title>
    <style type="text/css">

      body {
        background-color: white;
	margin: 25px;
      }

      body, input {
	color: #222222;
	font-family: Arial, sans-serif;
	font-size: 10pt;
      }

      h1 {
        font-size: 20pt;
/**
 * Send Comment to FF Function
 *
 * This function adds comment to FF entry if
 * Send comments to FF option is true
 *
 * @param integer
 *
 * @return bool
 *
 */
function send_admin_comment_to_ff($comment_ID)
{
    global $wpdb, $ff_username, $ff_remote_key;
    $ff = new FriendFeed($ff_username, $ff_remote_key);
    if (!$ff) {
        return false;
    } else {
        $ff_send_admin_comment = get_option('ff_send_admin_comment');
        if (empty($ff_send_admin_comment)) {
            return false;
        } else {
            // Eklenen yorumun bilgilerini al
            $comment = get_commentdata($comment_ID, 1);
            $comment_post_ID = $comment['comment_post_ID'];
            $ff_item = $wpdb->get_row($wpdb->prepare('SELECT * FROM ' . TABLE_NAME . ' WHERE post_id = %d', $comment_post_ID));
            if (!$ff_item) {
                return false;
            } else {
                // Yorumu yapan kullanıcı sitede kayıtlı mı?
                if (wp_ff_user_is_exists($comment['user_id'])) {
                    // Kullanıcının sitedeki rolü
                    $user_role = wp_ff_get_user_role($comment['user_id']);
                    // Eğer admin ise
                    if ($user_role['administrator'] == 1) {
                        // FF API @ sorunu için hack :)
                        $comment = str_replace('@', ' @', $comment['comment_content']);
                        // Eğer Karakter Sayısı 512'den az ise tek yorum gönder
                        if (mb_strlen($comment['comment_content']) < 512) {
                            $comment_id = $ff->add_comment($ff_item->friendfeed_id, $comment);
                        } else {
                            $link = get_permalink($comment['comment_post_ID']) . '#comment-' . $comment_ID;
                            $link_character_count = mb_strlen($link, 'UTF-8');
                            $limit = 500 - ($link_character_count + 5);
                            // Yorumu limitlemek lazım
                            $comment = mb_substr($comment, 0, $limit, 'UTF-8');
                            $comment_content = $comment . '... ' . $link;
                            $comment_id = $ff->add_comment($ff_item->friendfeed_id, $comment_content);
                        }
                        if ($comment_id) {
                            wp_ff_add_comment_to_blacklist($comment_id);
                            return true;
                        } else {
                            return false;
                        }
                    } else {
                        return false;
                    }
                } else {
                    return false;
                }
            }
        }
    }
}