Package net.oauth.client

Examples of net.oauth.client.OAuthResponseMessage


      if (authenticate) {
        assert accessor.accessToken != null && accessor.tokenSecret != null
        : "Need OAuth access token and secret for this method";
        request.addRequiredParameters(accessor);
      }
      OAuthResponseMessage response = client.access(request, getStyle(request));
      int statusCode = response.getHttpResponse().getStatusCode();
      if (statusCode != HttpResponseMessage.STATUS_OK) {
        throw new TwitterException(response.toOAuthProblemException());
      }
      return response.readBodyAsString();
    } catch (TwitterException t) {
      throw t;
    } catch (Exception e) {
      throw new TwitterException(e);
    }
View Full Code Here


            OAuthClient client = new OAuthClient(new HttpClient3());
            OAuthAccessor accessor = buildAccessor();

            OAuthMessage request = accessor.newRequestMessage(OAuthMessage.GET, endpointUrl + "Invoices" + "/" + invoiceId, null);
            request.getHeaders().add(new OAuth.Parameter("Accept", "application/pdf"));
            OAuthResponseMessage response = client.access(request, ParameterStyle.BODY);


            file = new File("Invoice-" + invoiceId + ".pdf");

            if (response != null && response.getHttpResponse() != null && (response.getHttpResponse().getStatusCode() / 2) != 2) {
                in = response.getBodyAsStream();
                out = new FileOutputStream(file);

                byte[] buffer = new byte[1024];
                int bytesRead = 0;
                while ((bytesRead = in.read(buffer)) != -1) {
                    out.write(buffer, 0, bytesRead);
                }
            } else {
                throw response.toOAuthProblemException();
            }

        } catch (OAuthProblemException ex) {
            throw new XeroClientException("Error getting PDF of invoice " + invoiceId, ex);
        } catch (Exception ex) {
View Full Code Here

TOP

Related Classes of net.oauth.client.OAuthResponseMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.