Java Code Examples for com.codename1.io.ConnectionRequest#addArgumentNoEncoding()
The following examples show how to use
com.codename1.io.ConnectionRequest#addArgumentNoEncoding() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SignIn.java From codenameone-demos with GNU General Public License v2.0 | 6 votes |
private void showFacebookUser(String token){ ConnectionRequest req = new ConnectionRequest(); req.setPost(false); req.setUrl("https://graph.facebook.com/v2.3/me"); req.addArgumentNoEncoding("access_token", token); InfiniteProgress ip = new InfiniteProgress(); Dialog d = ip.showInifiniteBlocking(); NetworkManager.getInstance().addToQueueAndWait(req); byte[] data = req.getResponseData(); JSONParser parser = new JSONParser(); Map map = null; try { map = parser.parseJSON(new InputStreamReader(new ByteArrayInputStream(data), "UTF-8")); } catch (IOException ex) { ex.printStackTrace(); } String name = (String) map.get("name"); d.dispose(); Form userForm = new UserForm(name, (EncodedImage) theme.getImage("user.png"), "https://graph.facebook.com/v2.3/me/picture?access_token=" + token); userForm.show(); }
Example 2
Source File: FacebookConnect.java From CodenameOne with GNU General Public License v2.0 | 6 votes |
@Override protected boolean validateToken(String token) { //make a call to the API if the return value is 40X the token is not //valid anymore final boolean[] retval = new boolean[1]; retval[0] = true; ConnectionRequest req = new ConnectionRequest() { @Override protected void handleErrorResponseCode(int code, String message) { //access token not valid anymore if (code >= 400 && code <= 410) { retval[0] = false; return; } super.handleErrorResponseCode(code, message); } }; req.setPost(false); req.setUrl("https://graph.facebook.com/v2.4/me"); req.addArgumentNoEncoding("access_token", token); NetworkManager.getInstance().addToQueueAndWait(req); return retval[0]; }
Example 3
Source File: SignIn.java From CodenameOne with GNU General Public License v2.0 | 6 votes |
private void showFacebookUser(String token){ ConnectionRequest req = new ConnectionRequest(); req.setPost(false); req.setUrl("https://graph.facebook.com/v2.3/me"); req.addArgumentNoEncoding("access_token", token); InfiniteProgress ip = new InfiniteProgress(); Dialog d = ip.showInifiniteBlocking(); NetworkManager.getInstance().addToQueueAndWait(req); byte[] data = req.getResponseData(); JSONParser parser = new JSONParser(); Map map = null; try { map = parser.parseJSON(new InputStreamReader(new ByteArrayInputStream(data), "UTF-8")); } catch (IOException ex) { ex.printStackTrace(); } String name = (String) map.get("name"); d.dispose(); Form userForm = new UserForm(name, (EncodedImage) theme.getImage("user.png"), "https://graph.facebook.com/v2.3/me/picture?access_token=" + token); userForm.show(); }
Example 4
Source File: SocialChat.java From codenameone-demos with GNU General Public License v2.0 | 5 votes |
@Override public void fetchData(String token, Runnable callback) { this.token = token; ConnectionRequest req = new ConnectionRequest() { @Override protected void readResponse(InputStream input) throws IOException { JSONParser parser = new JSONParser(); Map<String, Object> parsed = parser.parseJSON(new InputStreamReader(input, "UTF-8")); name = (String) parsed.get("name"); id = (String) parsed.get("id"); } @Override protected void postResponse() { callback.run(); } @Override protected void handleErrorResponseCode(int code, String message) { //access token not valid anymore if(code >= 400 && code <= 410){ doLogin(FacebookConnect.getInstance(), FacebookData.this, true); return; } super.handleErrorResponseCode(code, message); } }; req.setPost(false); req.setUrl("https://graph.facebook.com/v2.4/me"); req.addArgumentNoEncoding("access_token", token); NetworkManager.getInstance().addToQueue(req); }