正在查看: St.John's v1.0.9 应用的 MSGraphRequestWrapper.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: St.John's v1.0.9 应用的 MSGraphRequestWrapper.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.mcb.stjohnsemschool.utils;
import android.content.Context;
import android.util.Log;
import com.android.volley.DefaultRetryPolicy;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.Volley;
import cz.msebera.android.httpclient.protocol.HttpRequestExecutor;
import java.util.HashMap;
import java.util.Map;
import org.json.JSONObject;
public class MSGraphRequestWrapper {
public static final String MS_GRAPH_ROOT_ENDPOINT = "https://graph.microsoft.com/v1.0/me";
private static final String TAG = "MSGraphRequestWrapper";
public static void callGraphAPIUsingVolley(Context context, final String str, Response.Listener<JSONObject> listener, Response.ErrorListener errorListener) {
Log.d(TAG, "Starting volley request to graph");
if (str == null || str.length() == 0) {
return;
}
RequestQueue newRequestQueue = Volley.newRequestQueue(context);
JSONObject jSONObject = new JSONObject();
try {
jSONObject.put("key", "value");
} catch (Exception e) {
Log.d(TAG, "Failed to put parameters: " + e.toString());
}
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(0, MS_GRAPH_ROOT_ENDPOINT, jSONObject, listener, errorListener) {
public Map<String, String> getHeaders() {
HashMap hashMap = new HashMap();
hashMap.put("Authorization", "Bearer " + str);
return hashMap;
}
};
Log.d(TAG, "Adding HTTP GET to Queue, Request: " + jsonObjectRequest.toString());
jsonObjectRequest.setRetryPolicy(new DefaultRetryPolicy(HttpRequestExecutor.DEFAULT_WAIT_FOR_CONTINUE, 1, 1.0f));
newRequestQueue.add(jsonObjectRequest);
}
}