Java Code Examples for com.lidroid.xutils.http.RequestParams#addHeader()

The following examples show how to use com.lidroid.xutils.http.RequestParams#addHeader() . 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: PayHelperUtils.java    From Hook with Apache License 2.0 5 votes vote down vote up
public static void getTradeInfo(final Context paramContext, final String paramString) {
        Log.i("tag", "getTradeInfo:1 ");
        long l = System.currentTimeMillis();
        String str1 = getCurrentDate();
        String str2 = "https://mbillexprod.alipay.com/enterprise/simpleTradeOrderQuery.json?beginTime=" + (l - 864000000L) + "&limitTime=" + l + "&pageSize=20&pageNum=1&channelType=ALL";
        HttpUtils localHttpUtils = new HttpUtils(15000);
        localHttpUtils.configResponseTextCharset("GBK");
        RequestParams localRequestParams = new RequestParams();
        localRequestParams.addHeader("Cookie", paramString);
        localRequestParams.addHeader("Referer", "https://render.alipay.com/p/z/merchant-mgnt/simple-order.html?beginTime=" + str1 + "&endTime=" + str1 + "&fromBill=true&channelType=ALL");
        localHttpUtils.send(HttpRequest.HttpMethod.GET, str2, localRequestParams, new RequestCallBack() {
            public void onFailure(HttpException paramAnonymousHttpException, String paramAnonymousString) {
//                PayHelperUtils.sendmsg(PayHelperUtils.this, "服务器异常" + paramAnonymousString);
                Log.i("tag", "服务器异常");
            }

            public void onSuccess(ResponseInfo paramAnonymousResponseInfo) {
                String result = (String) paramAnonymousResponseInfo.result;
                try {
                    Log.i("tag", "getTradeInfo2" + result);
                    JSONArray array = new JSONObject(result).getJSONObject("result").getJSONArray("list");
                    if ((array != null) && (array.length() > 0)) {
                        String json = array.getJSONObject(0).getString("tradeNo");
                        Log.i("tag", "getTradeInfo3" + json);
                        Intent localIntent = new Intent();
                        localIntent.putExtra("tradeno", json);
                        localIntent.putExtra("cookie", paramString);
                        localIntent.setAction(Constans.ACTION_PAY_SUCCESS);
                        paramContext.sendBroadcast(localIntent);
//                        EventBus.getDefault().post(new MessageEvent(MessageEvent.MessageType.TRADENORECEIVED_ACTION,json,paramString));
                    }
                    return;
                } catch (Exception p) {
//                    PayHelperUtils.sendmsg(PayHelperUtils.this, "getTradeInfo异常" + paramAnonymousResponseInfo.getMessage());
                    Log.i("tag", "getTradeInfo异常" + p.getMessage());
                }
            }
        });
    }
 
Example 2
Source File: PullService.java    From ALLGO with Apache License 2.0 5 votes vote down vote up
private void getOnePull() {
	SharedPreferences sharedPref = this.getSharedPreferences("userdata",Context.MODE_PRIVATE);
	RequestParams params = new RequestParams();
       params.addQueryStringParameter("uid", sharedPref.getInt("uid", -1) + "");
       SharedPreferences sharedPref1 = this.getSharedPreferences("appdata",Context.MODE_PRIVATE);
	params.addHeader("Cookie","JSESSIONID="+sharedPref1.getString("SessionId", ""));
       
       HttpUtils http = new HttpUtils();
       http.send(HttpRequest.HttpMethod.GET,
       		declare.getHost_url() + "remind/unread",
               params,
               new RequestCallBack<String>() {

				@Override
                   public void onStart() {
                   	Log.i(TAG ,"Pull==>onStart" ) ;
                   }

                   @Override
                   public void onLoading(long total, long current, boolean isUploading) {
                   }

                   @Override
                   public void onSuccess(ResponseInfo<String> responseInfo) {
					readingParse(responseInfo.result);
                   }
                   @Override
                   public void onFailure(HttpException error, String msg) {
                   	Log.i(TAG ,"Pull==>error==>" +  msg ) ;
                   }
               });
}
 
Example 3
Source File: BillResultReceiver.java    From Hook with Apache License 2.0 4 votes vote down vote up
@Override
    public void onReceive(final Context context, Intent intent) {
//        Log.i("tag", "BillResultReceiver");
//        String money = intent.getStringExtra(Constans.BILL_MONEY);
//        String mark = intent.getStringExtra(Constans.BILL_MARK);
//        String type = intent.getStringExtra(Constans.BILL_TYPE);
//        String billNo = intent.getStringExtra(Constans.BILL_NO);
//        PushParam pushParam = new PushParam();
//        pushParam.setMark(mark);
//        pushParam.setMoney(money);
//        pushParam.setBillNo(billNo);
//        pushParam.setType(type);
//        Log.i("tag", "BillResultReceiver: mark:"+mark+"money:"+money+"billno:"+no+"type:"+type);

        final String tradeno = intent.getStringExtra("tradeno");
        String cookie = intent.getStringExtra("cookie");
        String url = "https://tradeeportlet.alipay.com/wireless/tradeDetail.htm?tradeNo=" + tradeno + "&source=channel&_from_url=https%3A%2F%2Frender.alipay.com%2Fp%2Fz%2Fmerchant-mgnt%2Fsimple-order._h_t_m_l_%3Fsource%3Dmdb_card";
        HttpUtils localHttpUtils = new HttpUtils(15000);
        localHttpUtils.configResponseTextCharset("GBK");
        RequestParams localRequestParams = new RequestParams();
        localRequestParams.addHeader("Cookie", cookie);
        localHttpUtils.send(HttpRequest.HttpMethod.GET, url, localRequestParams, new RequestCallBack() {
            @Override
            public void onSuccess(ResponseInfo responseInfo) {
                Log.i("tag", "onMessageEvent:" + responseInfo.result);
                Object localObject = Jsoup.parse((String) responseInfo.result).getElementsByClass("trade-info-value");
                if (((Elements) localObject).size() >= 5) {
                    String paramAnonymousResponseInfo = ((Elements) localObject).get(0).ownText();
                    String xx = ((Elements) localObject).get(1).ownText();
                    String xxx = ((Elements) localObject).get(2).ownText();
                    localObject = ((Elements) localObject).get(3).ownText();
                    PayHelperUtils.sendmsg(context,"付款成功alipay:订单号:"+ tradeno + "金额:" + paramAnonymousResponseInfo + "备注:" + (String) localObject);
                    Log.i("tag", "收到支付宝订单,订单号:" + tradeno + "金额:" + paramAnonymousResponseInfo + "备注:" + (String) localObject+"xx:"+xx+"xxx:"+xxx);
                    PushParam pushParam = new PushParam();
                    pushParam.setMark((String) localObject);
                    pushParam.setMoney(paramAnonymousResponseInfo);
                    pushParam.setBillNo(tradeno);
                    pushParam.setType("alipay");
                    pushParam.setState(1);
                    DBManager dbManager=new DBManager(context);
                    dbManager.updatePay(pushParam);
//                    Api.PUSH_ORDER_RESULT(context, pushParam, String.class, 1);
                }

            }

            @Override
            public void onFailure(HttpException error, String msg) {
                Log.i("tag", "服务器异常1");
            }
        });


    }
 
Example 4
Source File: NetUtil.java    From ALLGO with Apache License 2.0 4 votes vote down vote up
private void send(HttpRequest.HttpMethod arg0,RequestParams params){
	SharedPreferences sharedPref = context.getSharedPreferences("appdata",Context.MODE_PRIVATE);
	params.addHeader("Cookie","JSESSIONID="+sharedPref.getString("SessionId", ""));
	http = new HttpUtils();
	http.configCurrentHttpCacheExpiry(1000 * 1);
    http.send(arg0,
    		declare.getHost_url() + uri,
    		params,
            new RequestCallBack<String>() {

				@Override
                public void onStart() {
                	Log.i(TAG ,"onStart" ) ;
                }
				
                @Override
                public void onSuccess(ResponseInfo<String> responseInfo) {
                	Log.i(TAG, "Http==>"+responseInfo.result);
					try {
						jsonObject = new JSONObject(responseInfo.result);
						 if(jsonObject.getString("response").equals("error")){
							refresh.refresh(jsonObject.getJSONObject("error").getString("text"), -1);
						 }else if(jsonObject.getString("response").equals("notlogin")){
							 Toast.makeText(context, "登录过期,请重新登录", Toast.LENGTH_SHORT).show();
							 Intent intent = new Intent(context,LogOffACTIVITY.class);
							 intent.putExtra("action", 1);
							 context.startActivity(intent);
						 }else {
							 callback.getResult(jsonObject);
						 }
					} catch (JSONException e) {
						e.printStackTrace();
					}
                }
                @Override
                public void onFailure(HttpException error, String msg) {
                	Log.i(TAG ,"error==>" +  msg ) ;
                	refresh.refresh(msg, -1);
                }
            });
}