android - Polycom cURL to HTTP request -
i using polycom device make calls. need call number android device. polycom tutorial suggests use curl purpose. however, since android not support curl, know there anyway make request using http?
this curl command using-
curl --digest -u abc:xyz -d "<polycomipphone><url priority="critical">softkey:cancel </url> </polycomipphone>" --header "content-type: application/x-com-polycom-spipx" http://1.2.3.4/push
where, abc:xyz username/password
i unable understand http headers in case.
edit: polycom phone model vvx-550
edit 2: got working using code below:
public void makecall(){ httpclient client = new defaulthttpclient(); httppost post = new httppost("http://1.2.3.4/push"); post.setheader("content-type", "application/x-com-polycom-spipx"); if(isauthrequested){ digestscheme digestauth = new digestscheme(); digestauth.overrideparamter("algorithm", "md5"); digestauth.overrideparamter("realm", "push authentication"); digestauth.overrideparamter("nonce", nonce); digestauth.overrideparamter("qop", "0"); digestauth.overrideparamter("nc", "0"); digestauth.overrideparamter("cnonce", digestscheme.createcnonce()); header auth; try { auth = digestauth.authenticate(new usernamepasswordcredentials("username", "password"), post); post.addheader(auth); } catch (authenticationexception e2) { e2.printstacktrace(); } } httpentity entity = null; try { entity = new bytearrayentity(mxml.getbytes("utf-8")); post.setentity(entity); httpresponse response = null; try { response = client.execute(post); } catch (clientprotocolexception e1) { e1.printstacktrace(); } catch (ioexception e1) { e1.printstacktrace(); } try { if(!isauthrequested){ header[] authresp = response.getheaders("www-authenticate"); for(header : authresp){ log.d("log","header: "+he); string[] firstsplit = he.tostring().split(","); string[] secondsplit = firstsplit[1].split("="); nonce = secondsplit[1]; nonce = nonce.replaceall("\"", ""); log.d("log","nonce:"+nonce); isauthrequested = true; makecall(); } } string result = entityutils.tostring(response.getentity()); log.d("log", "string result: "+result); } catch (parseexception e) { e.printstacktrace(); } catch (ioexception e) { e.printstacktrace(); } } catch (unsupportedencodingexception e) { e.printstacktrace(); } }
Comments
Post a Comment