I wrote something but it doesn't work. if I want to update the
position i get an 400 request.
I have no idea whats the problem. can anyone help me?
package demo.server;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import oauth.signpost.OAuth;
import oauth.signpost.OAuthConsumer;
import oauth.signpost.OAuthProvider;
import oauth.signpost.basic.DefaultOAuthConsumer;
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 oauth.signpost.signature.SignatureMethod;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
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.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
public class ServerTest extends Activity {
String consumerkey = "xxx";
OAuthConsumer consumer = new CommonsHttpOAuthConsumer("xxx",
"xxxxxxx", SignatureMethod.HMAC_SHA1);
OAuthProvider provider = new DefaultOAuthProvider(consumer,
"https://fireeagle.yahooapis.com/oauth/request_token",
"https://fireeagle.yahooapis.com/oauth/access_token",
"https://fireeagle.yahoo.net/oauth/authorize");
String oauth_callback = "x-net-RepkaRouter://oauth-response/";
String consumerToken;
String consumerSecret;
String authUrl = null;
EditText text1;
EditText mNameField;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
String mobileAuthUrl = "https://fireeagle.yahoo.net/
mobile_auth/27951";
System.out.println("Fetching request token from Fire
Eagle...");
// we do not support callbacks, thus pass OOB
try {
//authUrl = provider.retrieveRequestToken("fireeagle://
authorized");
//authUrl =
provider.retrieveRequestToken(OAuth.OUT_OF_BAND);
authUrl = getOAuthProvider().retrieveRequestToken(
getString(R.string.callback_url));
} catch (OAuthMessageSignerException e) {
// TODO Auto-generated catch block
Log.v("TEST", "catch: auth url 1");
e.printStackTrace();
} catch (OAuthNotAuthorizedException e) {
Log.v("TEST", "catch: auth url 2");
// TODO Auto-generated catch block
e.printStackTrace();
} catch (OAuthExpectationFailedException e) {
Log.v("TEST", "catch: auth url 3");
// TODO Auto-generated catch block
e.printStackTrace();
} catch (OAuthCommunicationException e) {
Log.v("TEST", "catch: auth url 4");
// TODO Auto-generated catch block
e.printStackTrace();
}
Button btn_request = (Button)findViewById(R.id.btn_request);
btn_request.setOnClickListener(btnListener_request);
mNameField = (EditText) findViewById(R.id.eingabe);
Button btn_access = (Button)findViewById(R.id.btn_access);
btn_access.setOnClickListener(btnListener_access);
Button btn_update = (Button)findViewById(R.id.btn_update);
btn_update.setOnClickListener(btnListener_update);
TextView tv = (TextView)findViewById(R.id.requestToken);
tv.setText("Pressing Ok opens a Webbrowser. Enter this code: " +
consumer.getToken()+ " // " + authUrl);
consumerToken = consumer.getToken();
consumerSecret = consumer.getTokenSecret();
}
private OnClickListener btnListener_request = new
OnClickListener()
{
public void onClick(View v)
{
String url = authUrl;//"https://fireeagle.yahoo.net/mobile_auth/
27951";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
};
private OnClickListener btnListener_access = new OnClickListener()
{
public void onClick(View v)
{
TextView tv_code = (TextView)findViewById(R.id.txt_code);
BufferedReader br = new BufferedReader(new
InputStreamReader(System.in));
String code = null;
try {
code = br.readLine();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String bla = null;
try {
//provider.retrieveAccessToken(authUrl);
provider.retrieveAccessToken(mNameField.getText().toString());
} 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();
}
tv_code.setText(provider.getResponseParameters().values().toString());
}
};
private OnClickListener btnListener_update = new OnClickListener()
{
public void onClick(View v)
{ TextView tv3 = (TextView)findViewById(R.id.txt_update3);
StringEntity body = null;
try {
HttpPost request = new HttpPost("https://
fireeagle.yahooapis.com/api/0.1/update");
body = new StringEntity("city=hamburg&label="
+ URLEncoder.encode("Send via Signpost!",
"UTF-8"));
body.setContentType("application/x-www-form-
urlencoded");
request.setEntity(body);
//HttpGet request = new HttpGet("https://
fireeagle.yahooapis.com/api/0.1/user");
try {
consumer.sign(request);
} catch (OAuthExpectationFailedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
HttpClient httpClient = new DefaultHttpClient();
HttpResponse response =
httpClient.execute(request);
tv3.setText("Response: " +
response.getStatusLine() + "
statusline:" +response.getStatusLine().getStatusCode() + " "
+
response.getStatusLine().getReasonPhrase());
} catch (OAuthMessageSignerException e) {
Log.w("updater", e);
} catch (ClientProtocolException e) {
Log.w("updater", e);
} catch (IOException e) {
Log.w("updater", e);
}
}
};
private OAuthProvider oauthProvider;
private OAuthConsumer oauthConsumer;
protected OAuthProvider getOAuthProvider() {
if (null == oauthProvider) {
oauthProvider = new
DefaultOAuthProvider(getOAuthConsumer(),
getString(R.string.request_token_url),
getString(R.string.access_token_url),
getString(R.string.authorization_url));
}
return oauthProvider;
}
protected OAuthConsumer getOAuthConsumer() {
if (null == oauthConsumer) {
oauthConsumer = new DefaultOAuthConsumer(
getString(R.string.consumer_key),
getString(R.string.consumer_secret),
SignatureMethod.HMAC_SHA1);
oauthConsumer.setTokenWithSecret(getAccessToken(),
getAccessTokenSecret());
}
return oauthConsumer;
}
protected static final String ACCESS_TOKEN = "access_token";
protected static final String ACCESS_TOKEN_SECRET =
"access_token_secret";
protected String getAccessToken() {
return getPreferences(MODE_PRIVATE).getString(ACCESS_TOKEN,
null);
}
protected String getAccessTokenSecret() {
return getPreferences(MODE_PRIVATE)
.getString(ACCESS_TOKEN_SECRET, null);
}
}
On 12 Mrz., 10:01, Merdica <[email protected]> wrote:
> I tried your fireeagle code for android. I downloaded the source and
> the .jar. But I get a error message in eclipse:
> " Link of class 'Ljfireeagle/FireEagleClient$1;' failed. Could not
> find class 'jfireeagle.FireEagleClient$1', referenced from method
> jfireeagle.FirEagleClient.<init> "
> Can you say me whats wrong?
>
> On 11 Mrz., 03:42, Sean Sullivan <[email protected]> wrote:
>
> > I built this Fire Eagle app in 2008:
>
> > http://code.google.com/p/jfireeagle/wiki/Android
>
> > http://code.google.com/p/jfireeagle/source/browse/#svn/trunk
>
> > The code is slightly out of date. I'm planning to update the app soon.
>
> > Sean
>
> > On Tue, Mar 9, 2010 at 8:22 AM, Merdica <[email protected]> wrote:
> > > hello,
>
> > > I'm looking after a simple example how to connect with an android app
> > > to fire eagle.
> > > All examples I found don't work.
> > > Please can anyone help me? I need only simple example how to request
> > > an get access.
>
> > > thanks
>
>
--
You received this message because you are subscribed to the Google Groups
"OAuth" 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/oauth?hl=en.