thank you very much Ernandes.....



On Aug 18, 6:40 pm, "Ernandes Jr." <[email protected]> wrote:
> OK!
>
> I am working on this issue. Hope to get a fix for that very soon.
>
> Regards,
> Ernandes
>
> On Wed, Aug 18, 2010 at 8:48 AM, LINUXGEEK <[email protected]> wrote:
> > yep..
> > am running it in blackberry
>
> > On Aug 18, 4:33 pm, "Ernandes Jr." <[email protected]> wrote:
> > > Are you running it on a Blackberry? :)
>
> > > On Wed, Aug 18, 2010 at 8:29 AM, LINUXGEEK <[email protected]>
> > wrote:
> > > > hello Ernandes up to now is studied your code but  i am getting
> > > > structed while using the send() in your twitter api me 1.3
>
> > > > thanks for the replay..
>
> > > > On Aug 18, 3:53 pm, "Ernandes Jr." <[email protected]> wrote:
> > > > > Hi,
>
> > > > > Check my xAuth implementation in TwAPIme,www.twapime.com. Maybe you
> > can
> > > > > find what's wrong with your code.
>
> > > > > Regards,
> > > > > Ernandes
>
> > > > > On Wed, Aug 18, 2010 at 7:42 AM, Tom van der Woerdt <[email protected]>
> > > > wrote:
>
> > > > > > The problem is that the last time I did Java (this is Java, right?)
> > was
> > > > > > ages ago (I was 12 back then) so I don't really know what the code
> > is
> > > > > > doing. The code looks fine to me, but like I said, I don't know
> > Java
> > > > > > very well.
>
> > > > > > Can you show the actual request you make, instead of code? Like the
> > > > > > "POST /1/statuses/update.json HTTP/1.1" part. Also include the base
> > > > > > string which you use.
>
> > > > > > Tom
>
> > > > > > On 8/18/10 12:38 PM, LINUXGEEK wrote:
> > > > > > > Thanks for the replay i was waiting for your replay
>
> > > > > > > here is my post body
>
> > > > > > > String postBody = "status="
> > > > > > >                               + URLUTF8Encoder.encode("Test
> > > > message");
>
> > > > > > > here is the base String
>
> > > > > > > String baseString = "POST&"
> > > > > > >                               + URLUTF8Encoder
> > > > > > >                                               .encode("
> > > > > >http://api.twitter.com/1/statuses/update.json";)
> > > > > > >                               + "&oauth_consumer_key%3D" + "my
> > > > consumer
> > > > > > key"
> > > > > > >                               +
> > "%26oauth_nonce%3D"+oauth_nonce+"a"
> > > > > > >                               +
> > > > > > "%26oauth_signature_method%3D"+oauth_signature_method
> > > > > > >                               + "%26oauth_token%3D"+auth_token
> > > > > > >                               +
> > > > "%26oauth_timestamp%3D"+oauth_timestamp
> > > > > > >                               +
> > "%26oauth_version%3D"+oauth_version +
> > > > > > "%26"
> > > > > > >                               + URLUTF8Encoder.encode(postBody);
>
> > > > > > >       String signingSecret = URLUTF8Encoder.encode("my Secret
> > key")+
> > > > "&"
> > > > > > +
> > > > > > > URLUTF8Encoder.encode("auth_secret");
>
> > > > > > > here is my signature
>
> > > > > > >               String signature =
> > > > > > URLUTF8Encoder.encode(hmacsha1(signingSecret,
> > > > > > > baseString));
>
> > > > > > > here is my header
>
> > > > > > > String header = new StringBuffer("OAuth oauth_nonce=\"").append(
> > > > > > >                               oauth_nonce).append(
> > > > > > >                               "\",
> > > > oauth_signature_method=\"").append(
> > > > > > >                               oauth_signature_method).append(
> > > > > > >                               "\", oauth_timestamp=\"").append(
> > > > > > >                               oauth_timestamp).append(
> > > > > > >                               "\",
> > oauth_consumer_key=\"").append("my
> > > > > > consumer key")
>
> > .append("\",oauth_token=\"").append(
>
> > > > token.getToken()).append(
> > > > > > >                                               "\",
> > > > > > oauth_signature=\"").append(
> > > > > > >                                               signature).append(
> > > > > > >                                               "\",
> > > > > > oauth_version=\"").append(oauth_version).append(
> > > > > > >                                               "\"").toString();
>
> > > > > > > one more question here
> > > > > > > when i am making the http request do i need to write the post
> > body to
> > > > > > > the outputStream..
>
> > > > > > > and tell me what should i change in the above code...
>
> > > > > > > On Aug 18, 3:28 pm, Tom van der Woerdt <[email protected]> wrote:
> > > > > > >> Hi,
>
> > > > > > >> That's a lot of code, but I prefer to know what it is doing over
> > the
> > > > > > >> actual code. So: can you post a request which you make to
> > Twitter,
> > > > and
> > > > > > >> can you give the Base String which you use for generating the
> > > > signature?
>
> > > > > > >> Tom
>
> > > > > > >> On 8/18/10 8:08 AM, LINUXGEEK wrote:
>
> > > > > > >>> private void StatusUpdate() throws CryptoTokenException,
> > > > > > >>>                    CryptoUnsupportedOperationException,
> > IOException
> > > > {
>
> > > > > > >>>            String oauth_signature_method = "HMAC-SHA1";
> > > > > > >>>            String oauth_timestamp =
> > String.valueOf(timestamp());
> > > > > > >>>            String oauth_nonce = createNonce(oauth_timestamp);
> > > > > > >>>            String oauth_version = "1.0";
>
> > > > > > >>>            String postBody = "status="
> > > > > > >>>                            + URLUTF8Encoder.encode("Finally i
> > got
> > > > > > success");
>
> > > > > > >>>            String baseString = "POST&"
> > > > > > >>>                            + URLUTF8Encoder
> > > > > > >>>                                            .encode("
> > > > > >https://api.twitter.com/1/statuses/update.json";)
> > > > > > >>>                            + "&oauth_consumer_key%3D" + "my
> > > > consumer
> > > > > > key"
> > > > > > >>>                            + "%26oauth_nonce%3D" + oauth_nonce
> > > > > > >>>                            + "%26oauth_signature_method%3D" +
> > > > > > oauth_signature_method
> > > > > > >>>                            + "%26oauth_token%3D" +
> > token.getToken()
> > > > > > >>>                            + "%26oauth_timestamp%3D" +
> > > > oauth_timestamp
> > > > > > >>>                            + "%26oauth_version%3D" +
> > oauth_version
> > > > +
> > > > > > "%26"
> > > > > > >>>                            + URLUTF8Encoder.encode(postBody);
> > > > > > >>>            String signingSecret = URLUTF8Encoder
> > > > > > >>>                            .encode("my consuer Secret")
> > > > > > >>>                            + "&" +
> > > > > > URLUTF8Encoder.encode(token.getSecret());
> > > > > > >>>            String signature = hmacsha1(signingSecret,
> > baseString);
> > > > > > >>>            Dialog.alert(signature);
> > > > > > >>>            String header = new StringBuffer("OAuth
> > > > > > oauth_nonce=\"").append(
>
> > > >  URLUTF8Encoder.encode(oauth_nonce)).append(
> > > > > > >>>                            "\",
> > oauth_signature_method=\"").append(
>
> > > > > >  URLUTF8Encoder.encode(oauth_signature_method)).append(
> > > > > > >>>                            "\", oauth_timestamp=\"").append(
>
> > > > > >  URLUTF8Encoder.encode(oauth_timestamp)).append(
> > > > > > >>>                            "\",
> > oauth_consumer_key=\"").append("my
> > > > > > consumer key")
> > > > > > >>>                            .append("\",oauth_token=\"").append(
>
> > > > > >  URLUTF8Encoder.encode(token.getToken())).append(
> > > > > > >>>                                            "\",
> > > > > > oauth_signature=\"").append(
>
> > > > > >  URLUTF8Encoder.encode(signature)).append(
> > > > > > >>>                                            "\",
> > > > > > oauth_version=\"").append(oauth_version).append(
> > > > > > >>>                                            "\"").toString();
> > > > > > >>>            UpdateMyNewStatus(header, postBody);
> > > > > > >>>    }
>
> > > > > > >>>    public static void UpdateMyNewStatus(String auth_header,
> > String
> > > > > > body)
> > > > > > >>> {
> > > > > > >>>            String url = "
> > > >http://api.twitter.com/1/statuses/update.json
> > > > > > ";
> > > > > > >>>            HttpConnection httpConn = null;
> > > > > > >>>            InputStream input = null;
> > > > > > >>>            OutputStream os = null;
> > > > > > >>>            try {
>
> > > > > > >>>                    httpConn = (HttpConnection)
> > Connector.open(url
> > > > > > >>>                                    +
> > > > > > ConnectionUtils.getConnectionPerameter());
>
> > > > > >  httpConn.setRequestMethod(HttpProtocolConstants.HTTP_METHOD_POST);
>
> >  httpConn.setRequestProperty("WWW-Authenticate",
> > > > > > >>>                                    "OAuth realm=
> > > >http://twitter.com/";);
> > > > > > >>>                    httpConn.setRequestProperty("Content-Type",
>
> > > > > >  "application/x-www-form-urlencoded");
> > > > > > >>>                    String authHeader = auth_header;
> > > > > > >>>                    httpConn.setRequestProperty("Authorization",
> > > > > > authHeader);
>
> > > > > > >>>                    // write post body
> > > > > > >>>                    String postBody = body;
>
> >  httpConn.setRequestProperty("Content-Length",
> > > > > > Integer
>
> > > > > >  .toString(postBody.getBytes().length));
> > > > > > >>>                    os = httpConn.openOutputStream();
> > > > > > >>>                    os.write(postBody.getBytes());
> > > > > > >>>                    os.close();
> > > > > > >>>                    os = null;
>
> > > > > > >>>                    input = httpConn.openDataInputStream();
>
> > > > > > >>>                    int resp = httpConn.getResponseCode();
> > > > > > >>>                    Dialog.alert(httpConn.getResponseMessage());
>
> > > > > > >>>                    if (resp == HttpConnection.HTTP_OK) {
>
> > > > > > >>>                            StringBuffer buffer = new
> > > > StringBuffer();
> > > > > > >>>                            int ch;
> > > > > > >>>                            while ((ch = input.read()) != -1) {
> > > > > > >>>                                    buffer.append((char) ch);
> > > > > > >>>                            }
> > > > > > >>>                            String content = buffer.toString();
>
> ...
>
> read more »

Reply via email to