java 發起http post請求

SamiraLedbe 8年前發布 | 1K 次閱讀 Java HTTP
/**
     * Creates the request "https://www.mycallaccount.com/ot/triggerID1.asp".
     * Customer didn't provide public API for this service. Used Fiddler2 to
     * grab data and emulate request through browser
     * 
     * @param callbackNumber
     *            callback number
     * @return the http post
     */
    private HttpPost createRequestToMycallaccountSite(String callbackNumber) {
        String value = String.format(
                "Did=%s&Password=%s&LegBPhone=%s&tempCB=%s&B1=Trigger",
                mSettings.getLogin(), mSettings.getPassword(),
                Uri.encode(mDialingContact.getNumber()),
                Uri.encode(callbackNumber));
        HttpPost post = new HttpPost(
                "https://www.mycallaccount.com/ot/Di_Trigger_Now31.asp");
        ByteArrayEntity entity = new ByteArrayEntity(value.getBytes());
        post.addHeader("Content-Type", "application/x-www-form-urlencoded");
        post.setEntity(entity);
        return post;
    }
 本文由用戶 SamiraLedbe 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!