Skip to content

Commit

Permalink
updated the sources and the lib
Browse files Browse the repository at this point in the history
  • Loading branch information
adin234 committed Dec 5, 2013
1 parent e4fa9b3 commit c2d0d6d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
Binary file modified Android/lib/GlobeApiWrapper.zip
Binary file not shown.
11 changes: 11 additions & 0 deletions Android/src/com/globelabs/api/GlobeApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;

Expand Down Expand Up @@ -59,4 +60,14 @@ protected void __curlPost(String url, List<NameValuePair> fields, PostRequestHan
e.printStackTrace();
}
}

protected void __curlGet(String url, PostRequestHandler handler) {
HttpClient client = new DefaultHttpClient();
HttpGet get = new HttpGet(url);
HttpRequestAsyncTask task = new HttpRequestAsyncTask();
task.setClient(client);
task.setGet(get);
task.setHandler(handler);
task.execute();
}
}
13 changes: 12 additions & 1 deletion Android/src/com/globelabs/api/HttpRequestAsyncTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
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.util.EntityUtils;

Expand All @@ -15,6 +16,7 @@
public class HttpRequestAsyncTask extends AsyncTask<String, Void, String> {
HttpClient client;
HttpPost post;
HttpGet get;
String responseString="";
Method method;
PostRequestHandler handler;
Expand All @@ -31,14 +33,23 @@ public void setPost(HttpPost post) {
this.post = post;
}

public void setGet(HttpGet get) {
this.get = get;
}

public void setMethod(Method method) {
this.method = method;
}

@Override
protected String doInBackground(String... arg0) {
try {
HttpResponse responseGet = client.execute(post);
HttpResponse responseGet = null;
if(post!=null) {
responseGet = client.execute(post);
} else if (get!=null) {
responseGet = client.execute(get);
}
HttpEntity resEntityGet = responseGet.getEntity();
if (resEntityGet != null) {
responseString = EntityUtils.toString(resEntityGet);
Expand Down
6 changes: 6 additions & 0 deletions Android/src/com/globelabs/api/Sms.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ public Sms(String address, String version) {
this.version = version;
}

public void getMessages(PostRequestHandler handler) {
String url = "http://%s/smsmessaging/%s/inbound/registrations/%s/messages";
url = String.format(url, GlobeApi.API_ENDPOINT, "v1", this.address);
this.__curlGet(url, handler);
}

public void sendMessage(String accessToken, String sendTo, String message, PostRequestHandler handler) {
List<NameValuePair> parameters = new ArrayList<NameValuePair>();
parameters.add(new BasicNameValuePair("access_token", accessToken));
Expand Down

0 comments on commit c2d0d6d

Please sign in to comment.