Android SDK上的Facebook SDK显示了一个公共站点

时间:2012-11-16 07:44:12

标签: android facebook-android-sdk

我正在尝试做什么


Hello and Good Morning Guys,我想创建一个Facebook-Viewer女巫只显示我一个指定的网站,例如这一个:Some Random Facebook Site因为我不知道怎么做,我是看看Facebook API网站,它没有给我任何信息......

问题


因此,你可能会陷入困境,我不知道如何做到这一点。如果你能告诉我以下情况会很棒:

  1. 我是否需要开发人员密钥?
  2. 你能给我一些示例代码或一个很好的教程。
  3. 一些额外的信息,我想展示的Facebook网站是公开的(所以我不希望用户必须登录到fb)。

    提前为你们准备好了!

    最好的问候

    狩猎

2 个答案:

答案 0 :(得分:1)

以下是我认为您可以尝试的,您需要和开发人员密钥,并且必须创建一个Facebook应用程序。您可以阅读此link,了解这是如何完成的。

完成后,您可以使用FQL获取页面列表。 This link为您提供有关如何使用Facebook android SDK从Android App进行FQL查询的信息。

现在您想要的对象是Page。您可以使用适合您需要的参数进行查询。随机化结果并使用Facebook graph API.

显示页面

答案 1 :(得分:0)

解决问题的方法


我找到了一个解决方案,在我的情况下工作。需要出现的内容:

  1. Facebook Developers
  2. 上注册您的应用
  3. 页面需要发布并公开
  4. 从已注册的应用中获取de APP_ID和APP_SECRET,以及那些可以获得访问令牌的应用,如https://graph.facebook.com/oauth/access_token?type=client_cred&client_id="+APP_ID+"&client_secret="+APP_SECRET
  5. 以下是代码:


        private static final String ACCESS_TOKEN_QUERY = "https://graph.facebook.com/oauth/access_token?type=client_cred&client_id="+APP_ID+"&client_secret="+APP_SECRET;
    
            private static final String FEED_URL = "https://graph.facebook.com/"+PAGE_ID+"/feed?";
            private static String accesstoken = "";
            private static String jsonresponse = "";
    
            Context context;
    
    
                String line = null;
    
                final ArrayList<HashMap<String, String>> videolist = new ArrayList<HashMap<String, String>>();
    
                //Get AccessToken
                try{
                    URL url = new URL(ACCESS_TOKEN_QUERY); 
    
                    URLConnection conn = url.openConnection();
                    StringBuilder sb = new StringBuilder();
                    BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
    
                    //read d response till d end
                    while ((line = rd.readLine()) != null) {
                        sb.append(line + "\n");
                        }
                        accesstoken = sb.toString();
                        Log.v("log_tag", "Append String " + accesstoken);
                        } catch (Exception e) {
                        Log.e("log_tag", "Error converting result " + e.toString());
                        }
    
    
                //Get JSON
    
                try{
                    URL url = new URL(FEED_URL+accesstoken);
    
                    URLConnection conn = url.openConnection();
                    StringBuilder sb = new StringBuilder();
                    BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
    
                    while ((line = rd.readLine()) != null) {
                        sb.append(line + "\n");
                        }
                        jsonresponse = sb.toString();
                        Log.v("log_tag", "Append String " + jsonresponse);
    
                } catch (Exception e) {
                    Log.e("log_tag", "Error converting result " + e.toString());
                    }
    //Here you got the jsonresponse now, with which you can go on.
    

    好消息是你甚至不需要在你的应用程序中使用Facebook SDK。 最诚挚的问候

    狩猎