| | |
| | | return connectionHttp(url, "POST", data, "application/json"); |
| | | } |
| | | } |
| | | public static String postJson(String url, String data, String authorization) { |
| | | if(url.startsWith("https://")){ |
| | | return connection(url, "POST", data, "application/json", true, authorization); |
| | | }else{ |
| | | return connectionHttp(url, "POST", data, "application/json", authorization); |
| | | } |
| | | } |
| | | public static String uploadTempMedia(String urlString ,String fileUrl){ |
| | | HttpsURLConnection conn= null; |
| | | try { |
| | |
| | | |
| | | } |
| | | public static String connection(String url,String method,String data,String contentType,boolean ignoreSSL){ |
| | | return connection(url, method, data, contentType, ignoreSSL, null); |
| | | } |
| | | public static String connection(String url,String method,String data,String contentType,boolean ignoreSSL, String authorization){ |
| | | HttpsURLConnection connection = null; |
| | | try { |
| | | URL _url = new URL(url); |
| | |
| | | connection.setUseCaches(false); |
| | | if(contentType != null){ |
| | | connection.setRequestProperty("Content-Type", contentType); |
| | | } |
| | | if(authorization != null){ |
| | | connection.setRequestProperty("Authorization", authorization); |
| | | } |
| | | |
| | | if(ignoreSSL){ |
| | |
| | | return null; |
| | | } |
| | | public static String connectionHttp(String url,String method,String data,String contentType ){ |
| | | return connectionHttp(url, method, data, contentType, null); |
| | | } |
| | | public static String connectionHttp(String url,String method,String data,String contentType, String authorization ){ |
| | | HttpURLConnection connection = null; |
| | | try { |
| | | URL _url = new URL(url); |
| | |
| | | if(contentType != null){ |
| | | connection.setRequestProperty("Content-Type", contentType); |
| | | } |
| | | if(authorization != null){ |
| | | connection.setRequestProperty("Authorization", authorization); |
| | | } |
| | | |
| | | connection.connect(); |
| | | |