コード例 #1
0
 /**
  * Synchronously make a request to the Facebook Graph API with the given HTTP method and string
  * parameters. Note that binary data parameters (e.g. pictures) are not yet supported by this
  * helper function.
  *
  * <p>See http://developers.facebook.com/docs/api
  *
  * <p>Note that this method blocks waiting for a network response, so do not call it in a UI
  * thread.
  *
  * @param graphPath Path to resource in the Facebook graph, e.g., to fetch data about the
  *     currently logged authenticated user, provide "me", which will fetch
  *     http://graph.facebook.com/me
  * @param params Key-value string parameters, e.g. the path "search" with parameters {"q" :
  *     "facebook"} would produce a query for the following graph resource:
  *     https://graph.facebook.com/search?q=facebook
  * @param httpMethod http verb, e.g. "GET", "POST", "DELETE"
  * @throws IOException
  * @throws MalformedURLException
  * @return JSON string representation of the response
  */
 public String request(String graphPath, Bundle params, String httpMethod)
     throws FileNotFoundException, MalformedURLException, IOException {
   params.putString("format", "json");
   if (isSessionValid()) {
     params.putString(TOKEN, getAccessToken());
   }
   String url = (graphPath != null) ? GRAPH_BASE_URL + graphPath : RESTSERVER_URL;
   return Util.openUrl(url, httpMethod, params);
 }