Exemple #1
0
  /**
   * Invoke a non OAuth HTTP GET request on a remote host.
   *
   * <p>This is only used for the Flickr OAuth methods checkToken and getAccessToken.
   *
   * @param path The request path
   * @param parameters The parameters
   * @return The Response
   */
  @Override
  public Response getNonOAuth(String path, Map<String, String> parameters) {
    InputStream in = null;
    try {
      URL url = UrlUtilities.buildUrl(getHost(), getPort(), path, parameters);
      if (Flickr.debugRequest) {
        logger.debug("GET: " + url);
      }
      HttpURLConnection conn = (HttpURLConnection) url.openConnection();
      conn.setRequestMethod("GET");
      if (proxyAuth) {
        conn.setRequestProperty("Proxy-Authorization", "Basic " + getProxyCredentials());
      }
      setTimeouts(conn);
      conn.connect();

      if (Flickr.debugStream) {
        in = new DebugInputStream(conn.getInputStream(), System.out);
      } else {
        in = conn.getInputStream();
      }

      Response response = null;
      synchronized (mutex) {
        Document document = builder.parse(in);
        response = (Response) responseClass.newInstance();
        response.parse(document);
      }
      return response;
    } catch (IllegalAccessException e) {
      throw new FlickrRuntimeException(e);
    } catch (InstantiationException e) {
      throw new FlickrRuntimeException(e);
    } catch (IOException e) {
      throw new FlickrRuntimeException(e);
    } catch (SAXException e) {
      throw new FlickrRuntimeException(e);
    } finally {
      IOUtilities.close(in);
    }
  }
Exemple #2
0
 /**
  * Construct the BuddyIconUrl using {@code https} scheme.
  *
  * <p>If none available, return the <a
  * href="https://www.flickr.com/images/buddyicon.jpg">default</a>, or an URL assembled from farm,
  * iconserver and nsid.
  *
  * @see <a href="http://flickr.com/services/api/misc.buddyicons.html">Flickr Documentation</a>
  * @return The BuddyIconUrl
  */
 public String getSecureBuddyIconUrl() {
   return UrlUtilities.createSecureBuddyIconUrl(iconFarm, iconServer, id);
 }
Exemple #3
0
 /**
  * Construct the BuddyIconUrl.
  *
  * <p>If none available, return the <a
  * href="http://www.flickr.com/images/buddyicon.jpg">default</a>, or an URL assembled from farm,
  * iconserver and nsid.
  *
  * @see <a href="http://flickr.com/services/api/misc.buddyicons.html">Flickr Documentation</a>
  * @return The BuddyIconUrl
  * @deprecated use {@link #getSecureBuddyIconUrl() }
  */
 @Deprecated
 public String getBuddyIconUrl() {
   return UrlUtilities.createBuddyIconUrl(iconFarm, iconServer, id);
 }