Facebook rss feed不适用于公众

时间:2014-08-29 13:48:10

标签: android facebook facebook-graph-api rss

(1)使用Graph API

我跟着this link获取了公开的Feed。

Bundle param = new Bundle();
        param.putString("limit", "500");
        new Request(session, "/me/feed", param, HttpMethod.GET,
                new Request.Callback() {
                    public void onCompleted(Response response) {
                        feedJson = response.getGraphObject()
                                .getInnerJSONObject().toString();
                        }
                }).executeAsync();

根据上面的代码解析 feedJson 之后,我会收到帖子的网址和其他内容,但是如果我尝试从另一个fb帐户访问该链接,则该网址不适用于公众然后它拒绝访问。怎么办.. ??

(2)使用旧方式

另一种访问Feed的方式就像

i)https://graph.facebook.com/[page或您想要获取Feed的帐户名称

您为该网页或帐户获得 ID ,然后

ii)https://www.facebook.com/feeds/page.php?id= [您网页或帐户的ID]& format = rss20

然后点击输入就像 Facebook Syndication Error - SyndicationErrorFeed

怎么做.. ??

2 个答案:

答案 0 :(得分:1)

如果不直接使用API​​(需要您为能够访问该内容的用户提供访问令牌),您将无法访问受限制页面的Feed。  所以请让id无效。

我的代码已成功,请尝试此操作。

// Class with extends AsyncTask class
    private class LongOperation extends AsyncTask<String, Void, Void> {

        private final HttpClient Client = new DefaultHttpClient();
        private String Content;
        private String Error = null;
        private ProgressDialog Dialog = new ProgressDialog(getActivity());

        protected void onPreExecute() {
            Dialog.setMessage("Please Wait...");
            Dialog.show();
        }

        // Call after onPreExecute method
        protected Void doInBackground(String... urls) {
            try {
                // Server url call by GET method
                HttpGet httpget = new HttpGet(urls[0]);
                ResponseHandler<String> responseHandler = new BasicResponseHandler();
                Content = Client.execute(httpget, responseHandler);

                // Log.e("Content", "" + Content);
            } catch (ClientProtocolException e) {
                Error = e.getMessage();
                cancel(true);
                Log.e("ClientProtocolException", "" + e.getMessage());
            } catch (IOException e) {
                Error = e.getMessage();
                cancel(true);
                Log.e("IOException", "" + e.getMessage());
            }

            return null;
        }

        protected void onPostExecute(Void unused) {
            // NOTE: You can call UI Element here.

            Dialog.dismiss();
            socialfeedList = new ArrayList<SocialfeedDataset>();

            try {
                JSONObject jsonObject = new JSONObject(Content.toString());
                JSONArray jsonArray = jsonObject.getJSONArray("entries");
                Log.e("jsonArray", "" + jsonArray.length());
                for (int i = 0; i < jsonArray.length(); i++) {
                    String title = jsonArray.getJSONObject(i)
                            .optString("title");
                    Log.e("title", "" + title);
                }

            } catch (JSONException e) {
                e.printStackTrace();
            }

        }
    }

将您的网址作为参数传递:

new LongOperation().execute(Constant.Facebook_Feed);

答案 1 :(得分:0)

我认为Facebook RSS Feed不适用于私人帐户。任何人无需登录即可访问的公共帐户都有RSS帐户。