帮忙把python代码转换成Java代码
平衡之木 2012-07-12 02:56:48 def endSms(content,sms_rec): #发短信
try:
content=content.encode('utf8')
mobile=';'.join(sms_rec)
headers = {"Content-type":"application/x-www-form-urlencoded","Accept":"text/plain"}
params = urllib.urlencode({'username':'1329292480640CBO','password':'chinacacheCSP','mobile':mobile,'content':content})
conn = httplib.HTTPConnection("sms.chinacache.com",timeout=10)
conn.request(
method="POST",url="/ReceiverSms",body=params,headers=headers)
response=conn.getresponse()
data=response.read()
result=data.split(' ')[0]
if result == '0':
return True
else:
return False
except Exception:
exstr = traceback.format_exc()
return False