Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/269.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/182.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
Php facebook通过android应用程序订阅源_Php_Android_Json_Facebook - Fatal编程技术网

Php facebook通过android应用程序订阅源

Php facebook通过android应用程序订阅源,php,android,json,facebook,Php,Android,Json,Facebook,我正在尝试创建一个android应用程序,可以获得一个页面提要和照片。。。我需要一个例子。。。我尝试了以下json代码: 字符串feedUrl=”http://www.facebook.com/feeds/page.php?id=1374787696103514&format=json&start-索引=1,最大结果=10”; 但我不知道如何使用它。。。。顺便说一句,我对安卓系统还不熟悉。。。 谢谢你的帮助 此代码用于youtube。。。它正在工作,但我需要一个关于facebook的提示或示例:

我正在尝试创建一个android应用程序,可以获得一个页面提要和照片。。。我需要一个例子。。。我尝试了以下json代码: 字符串feedUrl=”http://www.facebook.com/feeds/page.php?id=1374787696103514&format=json&start-索引=1,最大结果=10”; 但我不知道如何使用它。。。。顺便说一句,我对安卓系统还不熟悉。。。 谢谢你的帮助

此代码用于youtube。。。它正在工作,但我需要一个关于facebook的提示或示例:

public class MainActivity extends ActionBarActivity {

    ListView videoList;
    ArrayList<String> videoArrayList =new ArrayList<String>();
    ArrayAdapter<String> videoAdapter;
    Context context;
    String feedUrl="http://gdata.youtube.com/feeds/api/users/omarsal2002/uploads?v=2&al"

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        context=this;
        videoList = (ListView) findViewById(R.id.videoList);

        videoAdapter = new ArrayAdapter<String>(this, R.layout.video_list_item,
                videoArrayList);
        videoList.setAdapter(videoAdapter);

        VideoListTask loaderTask=new VideoListTask();
        loaderTask.execute();

    }

    public class VideoListTask extends AsyncTask<Void, Void, Void> {

        ProgressDialog dialog;
        @Override
        protected void onPreExecute(){
            dialog=new ProgressDialog(context);
            dialog.setTitle("Loading Videos");
            dialog.show();
            super.onPreExecute();
        }
        @Override
        protected Void doInBackground(Void... params) {

            HttpClient client=new DefaultHttpClient();
            HttpGet getRequest=new HttpGet(feedUrl);
            try {
                HttpResponse responce=client.execute(getRequest);
                StatusLine statusline=responce.getStatusLine();
                int statusCode=statusline.getStatusCode();
                if(statusCode != 200){
                    return null;
                }

                InputStream jsonStream=responce.getEntity().getContent();
                BufferedReader reader = new BufferedReader(new InputStreamReader(jsonStream));
                StringBuilder builder=new StringBuilder();
                String line;
                while((line=reader.readLine())!=null)
                {
                    builder.append(line);
                }
                String jsonData=builder.toString();
                JSONObject json=new JSONObject(jsonData);
                JSONObject data=json.getJSONObject("data");
                JSONArray items=data.getJSONArray("items");

                for(int i=0;i<items.length();i++){
                    JSONObject video=items.getJSONObject(i);
                    //String title=video.getString("title");
                    videoArrayList.add(video.getString("title"));
                }

            } catch (ClientProtocolException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return null;
        }
        @Override
        protected void onPostExecute(Void result){
            dialog.dismiss();
            videoAdapter.notifyDataSetChanged();
            super.onPostExecute(result);
        }

    }
}
公共类MainActivity扩展了ActionBarActivity{
列表视图视频列表;
ArrayList videoArrayList=新的ArrayList();
阵列适配器;
语境;
字符串feedUrl=”http://gdata.youtube.com/feeds/api/users/omarsal2002/uploads?v=2&al"
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
上下文=这个;
videoList=(ListView)findViewById(R.id.videoList);
videoAdapter=新阵列适配器(此,R.layout.video\u列表项,
视频列表);
videoList.setAdapter(videoAdapter);
VideoListTask loaderTask=新建VideoListTask();
loaderTask.execute();
}
公共类VideoListTask扩展了AsyncTask{
进程对话;
@凌驾
受保护的void onPreExecute(){
dialog=新建进度对话框(上下文);
setTitle(“加载视频”);
dialog.show();
super.onPreExecute();
}
@凌驾
受保护的Void doInBackground(Void…参数){
HttpClient=new DefaultHttpClient();
HttpGet getRequest=新的HttpGet(feedUrl);
试一试{
HttpResponse response=client.execute(getRequest);
StatusLine StatusLine=response.getStatusLine();
int statusCode=statusline.getStatusCode();
如果(状态代码!=200){
返回null;
}
InputStream jsonStream=response.getEntity().getContent();
BufferedReader=new BufferedReader(new InputStreamReader(jsonStream));
StringBuilder=新的StringBuilder();
弦线;
而((line=reader.readLine())!=null)
{
builder.append(行);
}
字符串jsonData=builder.toString();
JSONObject json=新的JSONObject(jsonData);
JSONObject data=json.getJSONObject(“数据”);
JSONArray items=data.getJSONArray(“items”);

对于(int i=0;i您是使用FacebookSDK还是只想从请求中使用JSON对象?我想我必须在fbsdk之前学习如何使用JSON对象!!…所以我想使用JSON对象