I have done with it...

now am able to post my status through my application...

On Aug 19, 9:37 am, LINUXGEEK <yakubpash...@gmail.com> 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 <mhar...@twitter.com> 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 <yakubpash...@gmail.com> 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 <i...@tvdw.eu> 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 program a HTTP socket, what is the request
> > >> you make to twitter before getting this 401 error, and what is the base
> > >> string you use to generate the signature?
>
> > >> Tom
>
> > >> PS: People have said that I never mention the existence of libraries.
> > >> So, here I go:http://dev.twitter.com/pages/oauth_libraries
> > >> PPS: I dislike libraries.

Reply via email to