2009-12-29 36 views
2

我开始基于PHP的Facebook应用程序。 在Facebook的开发者页面的文档是相当混乱。facebook iframe php api

我选择了iframe方法来渲染画布页面。我在php中创建了我的应用程序,并托管在我的服务器上。现在应用程序在apps.facebook.com画布中正常加载。但事情是我无法使API调用工作。

我想知道的是如何将从api调用接收到的xml/JSON数据转换为有效的用户可读数据。我的意思是friends.get给我一堆uid。现在如何让它们显示为有效的用户配置文件图像缩略图或链接?

我对此很新。所以任何帮助,将不胜感激。我只需要知道如何使用Facebook API。

回答

2

我会建议使用FQL来代替 - 建立你的FQL查询将帮助你更好地理解FB下的内容以及如果你擅长SQL,你可以结合多个查询给你的朋友照片和他们的一个结果集中差异表的ID ...

使用FB fqlquery函数调用并将所需的列名传递到那里 - 例如您可以从下表中看到您的流:http://wiki.developers.facebook.com/index.php/Stream_%28FQL%29并且您可以根据此处给出的示例发出查询:http://wiki.developers.facebook.com/index.php/Fql.query

例如,这(只)给我从流表中的新闻源,我所有的朋友:

$logged_in_user = $facebook->get_loggedin_user(); 
select source_id, post_id, message, likes, created_time, updated_time from stream where source_id in (select uid from user where uid in (select uid2 from friend where uid1=' . $logged_in_user . ')) and filter_key=\'nf\' order by updated_time" 

您可以查询用户FQL表,朋友的图片URL,并在前端的郎的形象集装箱显示这些网址您的选择:http://wiki.developers.facebook.com/index.php/User_(FQL)

使用控制台进行测试您的疑问:http://developers.facebook.com/tools.php

,并使用MultiQuery http://wiki.developers.facebook.com/index.php/Fql.multiquery后,当你使用FQL查询

+0

但什么笑更舒适当我收到一个包含uid 1240079的xml数据时,我会这样做。我如何将给定的uid转换为用户帐户? – amit 2009-12-29 23:12:08

+0

从其他列中选择用户名first_name,last_name,pic_square,其中uid = 1240079 ,详情请参阅:http://wiki.developers.facebook.com/index.php/User_%28FQL%29 – sami 2009-12-30 12:19:11