JSON反序列化,图形API [英] Json Deserializing, graph api

查看:146
本文介绍了JSON反序列化,图形API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图访​​问使用图形API Facebook的用户信息(教育,家乡的细节)
是否有可能做到这一点的字符串URL = \"https://graph.facebook.com/me?fields=id,name,picture,bio,quotes,education,hometown&access_token=\" + oAuth.Token;

  JSON字符串= oAuth.WebRequest(oAuthFacebook.Method.GET,URL的String.Empty);
 的UserInfo UI = js.Deserialize<&的UserInfo GT;(JSON); StringBuilder的SB =新的StringBuilder();
SB = sb.Append(姓名:+ ui.name +< BR />中);
SB = sb.Append(< IMG SRC ='+ ui.picture +'ALT =''/>中);
SB = sb.Append(简介:+ ui.bio +< BR />中);
SB = sb.Append(行情:+ ui.quotes +< BR />中);
//这不起作用SB = sb.Append(故乡+ ui.hometown [0] +< BR />中);
//这不起作用SB = sb.Append(教育+ ui.education [0] +< BR />中);

我下面的UserInfo类

 公共类的UserInfo
    {
        公共字符串ID {搞定;组; }
        公共字符串名称{;组; }
        公共字符串图片{搞定;组; }
        公共字符串生物{搞定;组; }
        公共字符串引号{搞定;组; }
        从{得到公众的HometownInfo;组; }    }
    公共类HometownInfo
    {
        公共字符串ID {搞定;组; }
        公共字符串名称{;组; }
    }

请给我一些投入。我没有很多的.NET体验。另外,据我所知,ui.hometown [0]不访问用户故里信息的正确方法...
请指正
谢谢
SC


解决方案

 公共类FacebookUser
{
    公共字符串ID {搞定;组; }
    公共字符串名称{;组; }
    关于{获得公共字符串;组; }    公共字符串链接{搞定;组; }
    公共家乡故里=新故乡();
}公共类家乡
{
   公共字符串ID {搞定;组; }
   公共字符串名称{;组; }
}

i am trying to access the facebook user information(education, hometown details) using graph api Is it possible to do this string url = "https://graph.facebook.com/me?fields=id,name,picture,bio,quotes,education,hometown&access_token=" + oAuth.Token;

 string json = oAuth.WebRequest(oAuthFacebook.Method.GET, url, String.Empty);
 UserInfo ui = js.Deserialize<UserInfo>(json);

 StringBuilder sb = new StringBuilder();
sb = sb.Append("Name : " + ui.name + "<br/>");
sb = sb.Append("<Img src='" + ui.picture + "' alt='' />");
sb = sb.Append("Bio : " + ui.bio + "<br/>");
sb = sb.Append("Quotes : " + ui.quotes + "<br/>");
//This does not work      sb = sb.Append("hometown : " + ui.hometown[0] + "<br/>");
//This does not work      sb = sb.Append("Education : " + ui.education[0] + "<br/>");

I the following UserInfo class

public class UserInfo
    {
        public string id { get; set; }
        public string name { get; set; }
        public string picture { get; set; }
        public string bio { get; set; }
        public string quotes { get; set; }
        public HometownInfo from { get; set; }

    }
    public class HometownInfo
    {
        public string id { get; set; }
        public string name { get; set; }
    }

Please give me some inputs.. I dont have a lot of experience in .net. Also, I understand that ui.hometown[0] is not the correct way to access the user Hometown info... Please correct me Thanks SC

解决方案

public class FacebookUser
{
    public string    id { get; set; }
    public string  name { get; set; }
    public string about { get; set; }

    public string link { get; set; }
    public hometown hometown = new hometown();
}

public class hometown
{
   public string   id { get; set; }
   public string name { get; set; }
}

这篇关于JSON反序列化,图形API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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