什么时候使用getGraphObject和getGraphEdge [英] when do you use getGraphObject and getGraphEdge

查看:66
本文介绍了什么时候使用getGraphObject和getGraphEdge的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在基于php的网站上工作,并将一些facebook sdk集成到其中,以获取一些基本的用户信息.我遇到的一件事是,当我向图形发出请求时,如何知道应该使用getGraphObject还是getGraphEdge?我还没有看到任何直观的东西可以告诉我.

I'm working on a php based site and integrating some facebook sdk into it to get some basic user information. One thing I've been running into is, when I make a request to the graph, how do I know if I should be using getGraphObject or getGraphEdge? I'm not seeing anything intuitive yet to tell me that.

我正在运行php-sdk4->版本5

I'm running the php-sdk4 -> version 5

这是我昨晚遇到的一个例子.

Here's one example that I ran into last night..

$response = $fb->get('/me/friends', $fbToken);
$fbfriends = $response->getGraphEdge()->asArray();

文档中,如果您看一下php示例,他们使用getGraphObject.但是,当我使用它时,出现错误提示我应该使用Edge.有很多获取"功能,但是我看不到任何能告诉我如何使用的功能. getGraphObject,getGraphEdge,getGraphUser等.我希望对此有所了解,因为它对我来说是个猜谜游戏.

In the documentation, if you look at the php example, they use getGraphObject. But when I use it, I get an error telling me I should probably use the Edge. There are a lot of "get" functions, but I don't see anything that tells me how to know what to use. getGraphObject, getGraphEdge, getGraphUser, etc. I'd love some insight into this one, because it's been a guessing game for me.

推荐答案

基本上,何时:

  • 获取/{node-id},您应该使用getGraphNode()(不推荐使用getGraphObject())
  • 获取/{node-id-with-known-type}时,您应该使用getGraph{Type}().
    例如,先获取/me然后使用getGraphUser(),先获取/{event-id}然后使用getGraphEvent()
  • 获取/{node-id}/{edge-name},您应该使用getGraphEdge()(不推荐使用getGraphList())
  • 获取/{node-id}/{edge-name-with-children-known-type}时,您应该使用getGraphEdge({children-type-class}).
    例如,获取/me/albums然后使用getGraphEdge('GraphAlbum')
    节点类名称位于Facebook\GraphNodes命名空间中.
  • Getting /{node-id}, you should use getGraphNode() (getGraphObject() is deprecated)
  • Getting /{node-id-with-known-type}, you should use getGraph{Type}().
    For example, getting /me then use getGraphUser(), getting /{event-id} then use getGraphEvent()
  • Getting /{node-id}/{edge-name}, you should use getGraphEdge() (getGraphList() is deprecated)
  • Getting /{node-id}/{edge-name-with-children-known-type}, you should use getGraphEdge({children-type-class}).
    For example, getting /me/albums then use getGraphEdge('GraphAlbum')
    Nodes class name are in Facebook\GraphNodes namespace.

这篇关于什么时候使用getGraphObject和getGraphEdge的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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