Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- https://graph.facebook.com/me?access_token={ACCESS_TOKEN}
- {"success":true}
- null: HTTP/1.1 200 OK
- Access-Control-Allow-Origin: *
- Cache-Control: private, no-cache, no-store, must-revalidate
- Connection: keep-alive
- Content-Length: 16
- Content-Type: text/javascript; charset=UTF-8
- Date: Mon, 27 Mar 2017 19:53:18 GMT
- Expires: Sat, 01 Jan 2000 00:00:00 GMT
- facebook-api-version: v2.8
- Pragma: no-cache
- X-Android-Received-Millis: 1490644395774
- X-Android-Response-Source: NETWORK 200
- X-Android-Selected-Protocol: http/1.1
- X-Android-Sent-Millis: 1490644395542
- X-FB-Debug: {X-FB-DEBUG}
- x-fb-rev: 2916655
- x-fb-trace-id: {x-fb-trace-id}
- {
- "name": "First_name Surname",
- "id": "123456789"
- }
- class postRequest_runtimeTask implements Runnable
- {
- private String url;
- private HashMap<String, String> data;
- private postRequest_runtimeTask(String urlS, HashMap<String, String> dataS) {url = urlS; data = dataS;};
- @Override
- public void run()
- {
- URL requestUrl;
- try
- {
- requestUrl = new URL(url);
- HttpURLConnection conn = (HttpURLConnection) requestUrl.openConnection();
- conn.setReadTimeout(15000);
- conn.setConnectTimeout(15000);
- conn.setRequestMethod("POST");
- conn.setDoInput(true);
- conn.setDoOutput(true);
- /*
- for(String key : conn.getHeaderFields().keySet())
- {
- List<String> tmp = conn.getHeaderFields().get(key);
- for(String tmpval : tmp)
- {
- Log.v("Header " + key, tmpval);
- }
- }
- */
- /* Build String from HashMap for POST-Params */
- StringBuilder requestDataTmp = new StringBuilder();
- boolean first = true;
- for(Map.Entry<String, String> entry : data.entrySet())
- {
- if(first)
- {
- first = false;
- }
- else
- {
- requestDataTmp.append("&");
- }
- requestDataTmp.append(URLEncoder.encode(entry.getKey(), "UTF-8"));
- requestDataTmp.append("=");
- requestDataTmp.append(URLEncoder.encode(entry.getValue(), "UTF-8"));
- }
- String requestData = requestDataTmp.toString();
- OutputStream os = conn.getOutputStream();
- BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os, "UTF-8"));
- writer.write(requestData);
- writer.flush();
- writer.close();
- os.close();
- int responseCode=conn.getResponseCode();
- TEMP_BUFFER = "";
- if (responseCode == HttpsURLConnection.HTTP_OK)
- {
- String line;
- BufferedReader br=new BufferedReader(new InputStreamReader(conn.getInputStream()));
- while((line=br.readLine()) != null)
- {
- TEMP_BUFFER += line;
- }
- }
- else
- {
- //TEMP_BUFFER = "";
- Log.e("HTTP RESPONSE CODE", String.valueOf(responseCode) + ", url: " + url + ", content: nn" + TEMP_BUFFER);
- }
- }
- catch(Exception exp)
- {
- exp.printStackTrace();
- }
- }
- }
- Thread postRequest_runtimeTastAsync = new Thread(new postRequest_runtimeTask(url, data));
- postRequest_runtimeTastAsync.start();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement