2012-02-07 15 views
-2

私はWPFアプリケーションで作業しており、facebook Graph APIを使用してNews Feedを取得したいので、どのようにアクセスしてシリアライズすることもできます。Facebook Graph APIを使用してニュースフィードを取得する方法。

ありがとうございます。

+0

[何を試しましたか](http://mattgemmell.com/2008/12/08/what-have-you-tried/) –

+0

グラフAPIを使用してDictionary dic =新しい辞書(); var temp = obj.GetObject( "1078733634_2931461360458"、dic);データを表示することは困難です。あなたはもっと説明できますか? –

答えて

0

あなたはつもり利用Facebook.dll uはuがこの

public List<string> Facebook(string query) 
    { 
     // Facebook.FacebookAPI api = new FacebookAPI(); 

     List<string> list = new List<string>(); 
     string[] arr = new string[5]; 
     string result = null; 
     FacebookAPI api = new FacebookAPI(token); 
のように見えるかもしれ例

NuGet Package here..

やコードのためのC#を使用している場合、Visual Studioでのパッケージマネージャを使用してそれをダウンロードすることができます

//クエリはur検索条件です

 JSONObject q = api.Get("https://graph.facebook.com/search?q="+query+"&type=post"); 
     foreach (JSONObject item in q.Dictionary["data"].Array) 
     { 
      if (item.IsDictionary) 
      { 
       foreach (KeyValuePair<String,JSONObject> jso in item.Dictionary) 
       { 
        if (jso.Key == "message"/* || jso.Key == "name" || jso.Key == "description" || jso.Key == "link"*/) 
        { 
         for (int i = 0; i < 5; i++) 
         { 
          arr[i] = jso.Value.String; 

         } 
         list.Add (jso.Value.String); 

        } 
        else if (jso.Key == "likes") 
        { 
         foreach (JSONObject like in jso.Value.Dictionary["data"].Array) 
         { 
          foreach (KeyValuePair<String, JSONObject> lik in like.Dictionary) 
          { 
           if (lik.Key == "name") 
           { 
            result += lik.Value.String; 

           } 
           else if (lik.Key == "id") 
           { 
            result += lik.Value.String;  
           } 
          } 
         } 
         foreach (KeyValuePair<String, JSONObject> count in jso.Value.Dictionary) 
         { 
          if (count.Key == "count") 
          { 
           result += count.Value.String; 
          } 
         } 
        } 
        else if (jso.Key == "from") 
        { 
         foreach (KeyValuePair<String, JSONObject> froms in jso.Value.Dictionary) 
         { 
          if (froms.Key == "name") 
          { 
           result += froms.Value.String; 
          } 
         } 
        } 
       } 
      } 
      /* 
      else if (item.IsArray) 
      { 
       foreach (JSONObject j in item.Dictionary["data"].Array) 
       { 
        if (j.IsDictionary) 
        { 
         foreach (KeyValuePair<String,JSONObject> x in j.Dictionary) 
         { 
          result += (x.Key + " --- "+x.Value.String); 
         } 
        } 
       } 
      } 
      */ 
     } 
     return list; 
    } 

あなたはFacebookのグラフAPIに

を検索したいとFQLを使用し、参考になりますその本当に簡単

の希望があることを行うための別の方法がある何に進路変更ポストやクエリのことができます。

+0

@Midoさんありがとうございます。しかしこれを追加しようとしていますが、FacebookAPIは私にはerroを与えています。Facebookのdllにはないと思っていますが、そこにはもう一度感謝します。このバージョンのFacebook dllを使っています。 .1.0 –

+0

あなたは私にあなたが持っているエラーを教えてくださいできますか? :) – Mido

+0

お返事ありがとうございます.. –