I can't send a status

11 views
Skip to first unread message

Tsunaze

unread,
May 24, 2011, 5:55:59 PM5/24/11
to Empire Avenue API Discussion
I cant send a status : there is an error in the json : error: "No Data
Specified"
But i put the apikey, my ticker and my password. and the status . like
that &password=...&status=test , and this way
&password=...&status='test' , and this one too
&password=...&status="test", nothing worked .

Tsunaze

unread,
Jul 4, 2011, 5:33:04 PM7/4/11
to Empire Avenue API Discussion
No one ?

kevinu

unread,
Jul 4, 2011, 8:55:25 PM7/4/11
to empireave-ap...@googlegroups.com
You need to send a HTTP POST. You are doing a HTTP GET. 

Tsunaze

unread,
Jul 7, 2011, 11:01:39 AM7/7/11
to Empire Avenue API Discussion

So i read the part running query, but it doest say anything on POST
method. What kind of url is it ?

hiroshi

unread,
Jul 7, 2011, 11:05:23 AM7/7/11
to Empire Avenue API Discussion

kevinu

unread,
Jul 7, 2011, 11:22:37 AM7/7/11
to empireave-ap...@googlegroups.com
Guys guys guys, you need to understand the basics about HTTP GET and POST before you're going to get this working. 

Get and Post url's are the same. Get is basically just asking for data from the server. Post sends data to the server and then gets data back.


GOOGLE IS YOUR FRIEND!!!!




Tsunaze

unread,
Jul 14, 2011, 6:06:22 AM7/14/11
to Empire Avenue API Discussion
I followed your advice and here's my class to send a simple status .

public class SendStatus extends Activity implements OnClickListener{
EditText edit;
Button btn;
String status;
String url;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.sendstatus);
url = "https://api.empireavenue.com/profile/set/status/?
apikey=myapikey&username=ticker&password=password";
edit = (EditText)findViewById(R.id.send_status_edit_text);
btn = (Button)findViewById(R.id.send_status_btn);
btn.setOnClickListener(this);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
status = edit.getText().toString();
Toast.makeText(getApplicationContext(), status,
Toast.LENGTH_LONG).show();
grabURL(url);

}
private class GrabURL extends AsyncTask<String, Void, Void> {

ArrayList<NameValuePair> nameValuePairs = new
ArrayList<NameValuePair>();;
private ProgressDialog Dialog = new
ProgressDialog(SendStatus.this);

protected void onPreExecute() {
Dialog.setMessage("Sending status..");
Dialog.show();
}
protected Void doInBackground(String... urls) {
try{
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(url);
httppost.setEntity(new
UrlEncodedFormEntity(nameValuePairs));
httpclient.execute(httppost);

}catch(Exception e){
Log.e("log_tag", "Error in http connection
"+e.toString());
}

return null;
}
protected void onPostExecute(Void unused) {
Dialog.dismiss();
nameValuePairs.add(new BasicNameValuePair("status",status));
nameValuePairs.add(new BasicNameValuePair("username","ticker"));
nameValuePairs.add(new BasicNameValuePair("password","password"));
nameValuePairs.add(new BasicNameValuePair("apikey","myapikey"));
}
}
public void grabURL(String url){
new GrabURL().execute(url);
}
}

But it doesn't work . All the POST method is in the the
doInBackground, i don't know if you know some java but this is my
problem .

Tsunaze

unread,
Jul 14, 2011, 9:31:02 AM7/14/11
to Empire Avenue API Discussion
Okay so here's my mistake :
- i don't need to add username, password and api key in the
nameValuePairs

- nameValuePairs.add(new BasicNameValuePair("status", status)); have
to be in onpreExecute (Duh !).

- the url is wrong, the real one looks like this : url = "https://
api.empireavenue.com/profile/set/status/?
apikey=myapikey&username=ticker&password=password&status=";

All works for the best :) . Thanks for your interest and your help .
Reply all
Reply to author
Forward
0 new messages