Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/185.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用它显示Facebook页面帖子';android应用程序中的s图像_Android_Facebook_Facebook Graph Api - Fatal编程技术网

使用它显示Facebook页面帖子';android应用程序中的s图像

使用它显示Facebook页面帖子';android应用程序中的s图像,android,facebook,facebook-graph-api,Android,Facebook,Facebook Graph Api,我需要帮忙吗? 我开发了一个应用程序,可以查看最近20个Facebook页面提要(如果存在带有图像的帖子),我使用了这个图表 ()但是它给了我一个没有图像的文本帖子的结果。我如何显示和获取每个帖子的文本和图像,而不必在应用程序中登录Facebook。我终于解决了这个问题,感谢@sunil sunny你的评论,这很有帮助。 感谢@sunil sunny,我使用了这个api“”ya,我解决了这个问题,它工作正常,无需在你的应用程序中登录facebook, 遵循以下步骤: 1-在facebook开发者

我需要帮忙吗? 我开发了一个应用程序,可以查看最近20个Facebook页面提要(如果存在带有图像的帖子),我使用了这个图表
()但是它给了我一个没有图像的文本帖子的结果。我如何显示和获取每个帖子的文本和图像,而不必在应用程序中登录Facebook。我终于解决了这个问题,感谢@sunil sunny你的评论,这很有帮助。
感谢@sunil sunny,我使用了这个api“”

ya,我解决了这个问题,它工作正常,无需在你的应用程序中登录facebook, 遵循以下步骤:

1-在facebook开发者网站中,创建新项目,并使用access_令牌在下一步中使用 转到并单击“图形API资源管理器”按钮 2-使用截击或http请求或您喜欢的链接向该链接发出请求

String FACEBOOKURL="https://graph.facebook.com/YOUR Facebook PageID/feed?"
        +"fields=id,story,created_time,message,full_picture&access_token=/* put your access token that you take from step 1*/&limit=15"

3-以字符串形式从请求检索的数据可以这样转换

   JSONObject dataObj = null;
            Log.i("// url", URL.FACEBOOKURL);
            try {
                String story = "";
                String message = "";
                String created_time = "";
                String image = "";
                String id = "";
                dataObj = new JSONObject(response);
                JSONArray jdata = dataObj.getJSONArray("data");
                JSONObject jpaging = dataObj.getJSONObject("paging");
                final String previous = jpaging.getString("previous");
                final String next = jpaging.getString("next");
                for (int i = 0; i < jdata.length(); i++) {
                    JSONObject jsonObject = jdata.getJSONObject(i);
                    try {
                        message = jsonObject.getString("message");
                        story = "";
                    } catch (JSONException e) {
                        story = jsonObject.getString("story");

                        Log.i("//story", story);
                    }
                    created_time = jsonObject.getString("created_time");
                    try {
                        image = jsonObject.getString("full_picture");
                    } catch (JSONException e) {
                        image = "";
                    }
                    id = jsonObject.getString("id");
                    String[] parts = id.split("_");
                    String pageId = parts[0];
                    final String postId = parts[1];
                    Log.i("---//message", postId);
                    Log.i("---//image", image);
                    fbDataList.add(new FbData(postId, message, story, created_time, image));
JSONObject dataObj=null;
Log.i(“//url”,url.FACEBOOKURL);
试一试{
弦乐故事=”;
字符串消息=”;
创建的字符串_time=“”;
字符串图像=”;
字符串id=“”;
dataObj=新的JSONObject(响应);
JSONArray jdata=dataObj.getJSONArray(“数据”);
JSONObject jpaging=dataObj.getJSONObject(“分页”);
最终字符串previous=jpaging.getString(“previous”);
final String next=jpaging.getString(“next”);
对于(int i=0;i
我之所以使用try-catch,是因为在每一行输出数据中,它都会发生变化,例如full_picture返回,当您的帖子只有图像和“story”、“message”返回时,您可以在浏览器中运行链接,查看输出json并根据需要使用它

4-最后,您可以将输出列表放入recyclerView


我希望这会有所帮助:)

尝试“将&fields=full_图片添加到链接中当添加此部分时,结果就是没有如下文本的照片:“数据”:[{“full_图片”:“,“id”:“229161663845327_1059580214136797”}@sunilsunny嗨,你有没有想法将我们的应用程序的帖子发布到facebook WorkPlace页面?这是在android应用程序中没有“使用facebook登录”功能的情况下完成的吗?你能突出你所做的步骤并在评论中分享一些链接吗?我想阅读我的页面数据,并在android应用程序中显示,而不使用facebook登录。什么是
响应
?请详细说明