This is the code which i am using :-
package org.myTweet;
import oauth.signpost.OAuthProvider;
import oauth.signpost.basic.DefaultOAuthProvider;
import oauth.signpost.commonshttp.CommonsHttpOAuthConsumer;
import oauth.signpost.exception.OAuthCommunicationException;
import oauth.signpost.exception.OAuthExpectationFailedException;
import oauth.signpost.exception.OAuthMessageSignerException;
import oauth.signpost.exception.OAuthNotAuthorizedException;
import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.DefaultHttpClient;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
public class myTweet extends Activity {
Button twtbtn;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
/* final CommonsHttpOAuthConsumer consumer = new
CommonsHttpOAuthConsumer(
"EuMduRyU4fJcaVgPuN9vA",
"JsiDIvPTPhxcV7NgYkw5HVDO0HC41eI2A8ELVLwqqRU");
final OAuthProvider provider = new DefaultOAuthProvider("
http://twitter.com/oauth/request_token", "
http://twitter.com/oauth/access_token",
"http://twitter.com/oauth/authorize");
HttpClient client = new DefaultHttpClient();*/
twtbtn = (Button)findViewById(R.id.twtbtn);
twtbtn.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
// Context ctx whichever way you passing it in
CommonsHttpOAuthConsumer consumer = new
CommonsHttpOAuthConsumer(
"EuMduRyU4fJcaVgPuN9vA",
"JsiDIvPTPhxcV7NgYkw5HVDO0HC41eI2A8ELVLwqqRU");
OAuthProvider provider = new DefaultOAuthProvider("
http://twitter.com/oauth/request_token", "
http://twitter.com/oauth/access_token",
"http://twitter.com/oauth/authorize");
HttpClient client = new DefaultHttpClient();
String authUrl = null;
try {
* authUrl = provider.retrieveRequestToken(consumer,
"myTweet://twitt");
myTweet.this.startActivity(new
Intent(Intent.ACTION_VIEW, Uri.parse(authUrl)));*
} catch (OAuthMessageSignerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (OAuthNotAuthorizedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (OAuthExpectationFailedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (OAuthCommunicationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
}
}
I think the 2 lines of code which are in try - catch statement are causing
the problem since everytime i run this
i get an OUTHCommunicationException . Right now i am not calling the
callback lets just first navigate the app to twitter login page.
I have added following in manifest also :-
<intent-filter>
<action android:name="android.intent.action.VIEW"></action>
<category android:name="android.intent.category.DEFAULT"></category>
<category android:name="android.intent.category.BROWSABLE"></category>
<data android:scheme="myTweet" android:host="twitt"></data>
</intent-filter>
Let me know what is wrong in the application
On Fri, Feb 4, 2011 at 5:30 PM, Abhishek Talwar <
[email protected]> wrote:
> Hey guys
> I have completed my quest over facebook to post a simple text ,
> image , link in facebook.
> Now i have to do the same for twitter, any word over this topic will
> be appreciated .
> Thanks
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en