2012-01-24 7 views
0

親愛なる仲間のプログラマー、テキストステータスアップデートのみを取り出して表示したいのですが、スクリプトでこれをどのように指定できますか?

私はB & Bのウェブサイトwww.bordemundo.comに取り組んでいますし、私のウェブサイトのヘッダに私の非常に最新のFacebookのページのステータス更新を含めるようにしたいと思います。

私はJQueryに関してはひどくはないので、私はGoogleを使い、うまく動作するスクリプトを編集しました。私は本当に必要のない日付スタンプを取り除くことができました。ステータスが正確に1日に1回変わるからです。今度は、別のページの友人のフォトアルバムやリンクやデジタル情報を共有すると更新されることに気付きました。

自分で入力したステータスの更新を取得するだけです。私が編集したスクリプトを使って、どのように簡単にこれを管理できるのか、あなたの誰かが考えていますか?私は以下のコードを添付しました。

Thxを考慮すると本当に助けてくれてありがとう!

(function($) { 
$.fn.faceFeed = function(options) { 
    /** 
    * Configuration 
    * 
    * `pageName:` The name of your Facebook page. Required. 
    * `tokenGenerator:` Path to a file that will return a JSON access_token. If defined, this will take 
    *     priority over `accessToken`. 
    * `accessToken:` A token you generate at <https://developers.facebook.com/tools/explorer>. 
    * `dateClass:` The class of the `<span>` that contains your date "ago in words". Default: `post-date` 
    */ 
    var config = { 
     pageName: '', 
     tokenGenerator: '', // default: token.php 
     accessToken: '', 
     postsToFetch: 1 
    }; 
    $.fn.extend(config, options); 

    /** 
    * Converts "http://" links into <a> tags. 
    * 
    * @param {String} a block of text for which all "http://" links need conversion 
    * @return {String} the same block of text with URLs re-formatted. 
    */ 
    function linkify(text){ 
     if (text) { 
      text = text.replace(
       /((https?\:\/\/)|(www\.))(\S+)(\w{2,4})(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/gi, 
       function(url){ 
        var full_url = url; 
        if (!full_url.match('^https?:\/\/')) { 
         full_url = 'http://' + full_url; 
        } 
        return '<a href="' + full_url + '">' + url + '</a>'; 
       } 
      ); 
     } 
     return text; 
    } 

    /** 
    * Requests your page's status feed from the Open Graph and injects it as HTML into the 
    * element. 
    * 
    * @param {String} accessToken - A generated or provided access token for authorizing 
    *        with the API. 
    */ 
    function getPosts(accessToken, self) { 
     $.ajax({ 
      url: 'https://graph.facebook.com/'+config.pageName+'/feed', 
      type: 'GET', 
      data: { 
       access_token: accessToken, 
       limit: config.postsToFetch 
      }, 
      dataType: 'json', 
      success: function(response) { 
       self.html(''); 
       for (var c=0; c < response.data.length; c++) { 
        var status = response.data[c]; 
        var statusMessage = (status.message) ? status.message : status.story; 

        var txt = linkify(statusMessage); 

        var row = $('<span class="status"></span>').html(txt); 
        self.append(row); 
       } 
      } 
     }); 
    } 


    /* 
    * Runtime. 
    */ 
    return this.each(function() { 
     var self = $(this); 
     self.html('<p>Lade Neuigkeiten...</p>'); 

     if (config.tokenGenerator) { 
      $.ajax({ 
       url: config.tokenGenerator, 
       type: 'GET', 
       dataType: 'json', 
       success: function(generator) { 
        getPosts(generator.access_token, self); 
       } 
      }) 
     } else { 
      getPosts(config.accessToken, self); 
     } 
    }); 
}; 

})(jQueryの)

答えて

1

はい、読み取りページの状態にページ送りを読み取るからの変化。参照:http://developers.facebook.com/docs/reference/api/page/

また、あなたは

+0

を表示したいポスターのIDがあるアイテムのポスターは、あなたがそれを各項目のpost.from.idをチェックし、そのIDを確保することでなりたい人であることを確認することができますおい、たくさんのthx。私はこれらの2つの選択肢を少なくとも論理的に理解しています。 Unf。私はプログラマのようなものではありませんが、とにかく、私は提供されたリンクを読んで、多分考えを得るでしょう!ありがとうございました! –

+0

おい、私はあなたに大いに謝っている。この行を単に変更するだけで、 "url: 'https://graph.facebook.com/'+config.pageName+'/feed'、" to "url: 'https://graph.facebook.com/'+config.pageName+ '/ statuses'、 "それはcharmeのように動作します。実際に引っ張られるものは、私がボックスに入力するもののようです。あなたは本当に私の一日を作った。私はあなたが得るポイントをあなたにプッシュすることはできません。私はフォーラムで15点を必要としていることを伝え続けます。時々、私はここで質問を出し、できるだけ早くあなたは報われるでしょう! Saludos des Puerto Puerto Varas、compadre! –

+0

おかげで、喜んで助けになることができました。 – DMCS

関連する問題