[twitter-dev] Re: STATUS update after getting the Auth token using by using X-auth.
thank you Harris... On Aug 20, 11:40 am, Matt Harris wrote: > Glad to hear you got it worked out. > > Matt > > > > On Thu, Aug 19, 2010 at 10:55 PM, LINUXGEEK wrote: > > I have done with it... > > > now am able to post my status through my application... > > > On Aug 19, 9:37 am, LINUXGEEK wrote: > > > i have changed and tried but still the same issue.. > > > > please help me. > > > > thanks regards yakub pasha > > > > On Aug 18, 8:31 pm, Matt Harris wrote: > > > > > Hey, > > > > > Looking back at your original email I notice your base string has the > > URLhttps://api.twitter.com... but your request is > > tohttp://api.twitter.com > > > > > The base string and request URLs must be the same otherwise your > > request is invalid. > > > > > Hope that helps, > > > > > Matt Harris > > > > Developer Advocate, Twitterhttp://twitter.com/themattharris > > > > > On Aug 17, 2010, at 23:08, 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) {
Re: [twitter-dev] Re: STATUS update after getting the Auth token using by using X-auth.
Glad to hear you got it worked out. Matt On Thu, Aug 19, 2010 at 10:55 PM, LINUXGEEK wrote: > I have done with it... > > now am able to post my status through my application... > > On Aug 19, 9:37 am, LINUXGEEK wrote: > > i have changed and tried but still the same issue.. > > > > please help me. > > > > thanks regards yakub pasha > > > > On Aug 18, 8:31 pm, Matt Harris wrote: > > > > > Hey, > > > > > Looking back at your original email I notice your base string has the > URLhttps://api.twitter.com... but your request is > tohttp://api.twitter.com > > > > > The base string and request URLs must be the same otherwise your > request is invalid. > > > > > Hope that helps, > > > > > Matt Harris > > > Developer Advocate, Twitterhttp://twitter.com/themattharris > > > > > On Aug 17, 2010, at 23:08, 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.appen
[twitter-dev] Re: STATUS update after getting the Auth token using by using X-auth.
I have done with it... now am able to post my status through my application... On Aug 19, 9:37 am, LINUXGEEK wrote: > i have changed and tried but still the same issue.. > > please help me. > > thanks regards yakub pasha > > On Aug 18, 8:31 pm, Matt Harris wrote: > > > Hey, > > > Looking back at your original email I notice your base string has the > > URLhttps://api.twitter.com... but your request is > > tohttp://api.twitter.com > > > The base string and request URLs must be the same otherwise your request is > > invalid. > > > Hope that helps, > > > Matt Harris > > Developer Advocate, Twitterhttp://twitter.com/themattharris > > > On Aug 17, 2010, at 23:08, 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(); > > > Dialog.alert(content); > > > } > > > > } catch (Exception e) { > > > } finally { > > > try { > > >
[twitter-dev] Re: STATUS update after getting the Auth token using by using X-auth.
i have changed and tried but still the same issue.. please help me. thanks regards yakub pasha On Aug 18, 8:31 pm, Matt Harris wrote: > Hey, > > Looking back at your original email I notice your base string has the > URLhttps://api.twitter.com... but your request is tohttp://api.twitter.com > > The base string and request URLs must be the same otherwise your request is > invalid. > > Hope that helps, > > Matt Harris > Developer Advocate, Twitterhttp://twitter.com/themattharris > > On Aug 17, 2010, at 23:08, 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(); > > Dialog.alert(content); > > } > > > } catch (Exception e) { > > } finally { > > try { > > httpConn.close(); > > input.close(); > > } catch (IOException e) { > > e.printStackTrace(); > > } > > } > > } > > > i am using the above code.. > > > On Aug 17, 7:24 pm, Tom van der Woerdt wrote: > >> On 8/17/10 1:47 PM, LINUXGEEK wrote: > > >>> can any
[twitter-dev] Re: STATUS update after getting the Auth token using by using X-auth.
thanks for your replay Hrris.. i'll try it now and get back to you.. can you tell about the postbody i have mensioned the post body in the previous messages .. am i doing correct in that.. On Aug 18, 8:31 pm, Matt Harris wrote: > Hey, > > Looking back at your original email I notice your base string has the > URLhttps://api.twitter.com... but your request is tohttp://api.twitter.com > > The base string and request URLs must be the same otherwise your request is > invalid. > > Hope that helps, > > Matt Harris > Developer Advocate, Twitterhttp://twitter.com/themattharris > > On Aug 17, 2010, at 23:08, 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(); > > Dialog.alert(content); > > } > > > } catch (Exception e) { > > } finally { > > try { > > httpConn.close(); > > input.close(); > > } catch (IOException e) { > > e.printStackTrace(); > > } > > } > > } > > > i am using the above code.. > > > On Aug 17,
[twitter-dev] Re: STATUS update after getting the Auth token using by using X-auth.
here is my my postbody String postBody="status="+urlEncode("Test message"); String length=String.valueOf(postBody.length()); httpConn.setRequestProperty("Content-Length", length); is this correct usage in httpRequest.. On Aug 18, 8:31 pm, Matt Harris wrote: > Hey, > > Looking back at your original email I notice your base string has the > URLhttps://api.twitter.com... but your request is tohttp://api.twitter.com > > The base string and request URLs must be the same otherwise your request is > invalid. > > Hope that helps, > > Matt Harris > Developer Advocate, Twitterhttp://twitter.com/themattharris > > On Aug 17, 2010, at 23:08, 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(); > > Dialog.alert(content); > > } > > > } catch (Exception e) { > > } finally { > > try { > > httpConn.close(); > > input.close(); > > } catch (IOException e) { > >
[twitter-dev] Re: STATUS update after getting the Auth token using by using X-auth.
thank you very much Ernandes. On Aug 18, 6:40 pm, "Ernandes Jr." 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 wrote: > > yep.. > > am running it in blackberry > > > On Aug 18, 4:33 pm, "Ernandes Jr." wrote: > > > Are you running it on a Blackberry? :) > > > > On Wed, Aug 18, 2010 at 8:29 AM, LINUXGEEK > > 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." 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 > > > > 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 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"; > > >
Re: [twitter-dev] Re: STATUS update after getting the Auth token using by using X-auth.
Hey, Looking back at your original email I notice your base string has the URL https://api.twitter.com... but your request is to http://api.twitter.com The base string and request URLs must be the same otherwise your request is invalid. Hope that helps, Matt Harris Developer Advocate, Twitter http://twitter.com/themattharris On Aug 17, 2010, at 23:08, 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(); >Dialog.alert(content); >} > >} catch (Exception e) { >} finally { >try { >httpConn.close(); >input.close(); >} catch (IOException e) { >e.printStackTrace(); >} >} >} > > i am using the above code.. > > > On Aug 17, 7:24 pm, Tom van der Woerdt wrote: >> On 8/17/10 1:47 PM, LINUXGEEK wrote: >> >>> can any one help in updating the status of my twitter account by using >>> auth token and secret. >> >>> am getting 401 error while doing this.. >> >>> can any one give me code for updating the status. >> >> I could give you pseudocode, yes, but that will most likely be useless >> to you. >> >> Assuming that you know how to p
Re: [twitter-dev] Re: STATUS update after getting the Auth token using by using X-auth.
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 wrote: > yep.. > am running it in blackberry > > On Aug 18, 4:33 pm, "Ernandes Jr." wrote: > > Are you running it on a Blackberry? :) > > > > On Wed, Aug 18, 2010 at 8:29 AM, LINUXGEEK > 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." 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 > > > 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 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"; > > > > > > > >>>
[twitter-dev] Re: STATUS update after getting the Auth token using by using X-auth.
yep.. am running it in blackberry On Aug 18, 4:33 pm, "Ernandes Jr." wrote: > Are you running it on a Blackberry? :) > > On Wed, Aug 18, 2010 at 8:29 AM, LINUXGEEK 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." 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 > > 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 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";) > > > > >>>
Re: [twitter-dev] Re: STATUS update after getting the Auth token using by using X-auth.
Are you running it on a Blackberry? :) On Wed, Aug 18, 2010 at 8:29 AM, LINUXGEEK 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." 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 > 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 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%3
[twitter-dev] Re: STATUS update after getting the Auth token using by using X-auth.
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." 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 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 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" > > >>>
[twitter-dev] Re: STATUS update after getting the Auth token using by using X-auth.
String postBody="status="+urlEncode("Test message"); here is the base string i am using String baseString = "POST&" + URLUTF8Encoder .encode("http://api.twitter.com/1/statuses/update.xml";) + "&oauth_consumer_key%3D" + ""My Consumer key"" + "%26oauth_nonce%3D"+oauth_nonce + "%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); here is the HttpRequest httpConn = (HttpConnection) Connector.open(url + ConnectionUtils.getConnectionPerameter()); httpConn.setRequestMethod(HttpConnection.POST); httpConn.setRequestProperty("WWW-Authenticate", "OAuth realm=http://twitter.com/";); httpConn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); httpConn.setRequestProperty("Authorization", authHeader); httpConn.setRequestProperty("Content-Length",Integer .toString(postBody.getBytes().length)); os = httpConn.openOutputStream(); os.write(postBody.getBytes()); On Aug 18, 3:53 pm, "Ernandes Jr." 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 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 wrote: > > >> Hi, > > > >> That's a lot of code, but I prefer to know w
Re: [twitter-dev] Re: STATUS update after getting the Auth token using by using X-auth.
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 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 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, base
Re: [twitter-dev] Re: STATUS update after getting the Auth token using by using X-auth.
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 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( >>>
[twitter-dev] Re: STATUS update after getting the Auth token using by using X-auth.
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 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( > > > > URLUTF8E
Re: [twitter-dev] Re: STATUS update after getting the Auth token using by using X-auth.
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); > } > St
[twitter-dev] Re: STATUS update after getting the Auth token using by using X-auth.
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(); Dialog.alert(content); } } catch (Exception e) { } finally { try { httpConn.close(); input.close();