FACEBOOK OPENGRAPH-如何查询朋友和我自己 [英] FACEBOOK OPENGRAPH - How to query Friends and Myself

查看:72
本文介绍了FACEBOOK OPENGRAPH-如何查询朋友和我自己的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在将我的名字和我朋友的名字显示为单个节点时遇到问题,因为我只得到我朋友的名字而没有显示我的名字

I have a problem to display my name and my friends'' names as individual Nodes, as I only get my friends'' names without showing mine

public JsonObject GetMyProfile(string accessToken)
            {           
                FacebookClient client = new FacebookClient(accessToken);
                JsonObject me = client.Get("me/friends") as JsonObject;            
                return me;
            }



现在,这是我得到的XML结果
我想要的是将自己和我的朋友单独显示为节点





Right now this is the XML result I got
What I want is to display myself and my friends individually as a node



- <icedata xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="InformationConnectionsEngine.data">
      - <currentnode>
      + <node id="[{" name=":" gerald="" brisco="," 508219894="},{" helena="" tanvis="" loi="," 508637920="},{" maryam="" nasihah="," 514469729="},{" enguo="" teo="," 520924077="},{" kimberley="" xd="," 521541857="},{" noor="" haikal="," 522010705="},{" simin="" lim="," 524160253="},{" pam="" wong="," 524430008="},{" jiuying="" chen="," 531272219="},{" jeremy="" heng="" witha="" angmohname="," 531785558="},{" shanel="" see="," 533346883="},{" aaron="" 533822559="},{" soonboon="" kaichito="" mogu="," 534857954="},{" kai="" cannottank="," 537247625="},{" stacey="" goh="," 541347137="}</xml>"></node></currentnode></icedata>

推荐答案

我曾经做过类似的事情,但从没跟上. FB如您所知发送回JSON.基本上,我最终要做的是创建具有公共属性的类,并根据json响应使用反射将其分配给属性.

代码看起来像这样
I did something like that a while back never kept up with it. FB sends back JSON as you know. Basically what I ended up doing was create classes with public properties and used reflection to assign to the properties based on the json responses.

code looked like this
public static void jsonAssign(Type t, object otarg, JObject jo)
{
    PropertyInfo[] pis = t.GetProperties();
    object o;
    foreach (PropertyInfo pi in pis)
    {
        o = jo[pi.Name];
        if (o != null)
        {

            string val = o.ToString();
            int len = val.Length;
            if (val.StartsWith("\""))
                val = val.Substring(1, len - 1);
            len = val.Length;
            if (val.EndsWith("\""))
                val = val.Substring(0, len - 1);

            pi.SetValue(otarg, val, null);
        }
    }
}


这篇关于FACEBOOK OPENGRAPH-如何查询朋友和我自己的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆