Erlang:无法在post请求中发送表单参数

时间:2015-03-10 09:10:58

标签: python erlang

我的erlang脚本中有以下代码。但是在执行时,我在服务器中收到请求,但是我无法获取表单参数。

application:start(inets),                                                                                                                                                                  
Method = post,                                                                                                                                                                             
URL = "http://servername/cgi-bin/serverscript.py",                                                                                                                                     
Header = [],                                                                                                                                                                               
Type = "multipart/form-data",                                                                                                                                                              
Body = "{\"text\":\"data\"}",                                                                                                                                                            
HTTPOptions = [],                                                                                                                                                                          
Options = [],                                                                                                                                                                              
httpc:request(Method, {URL, Header, Type, Body}, HTTPOptions, Options).

以下是我用来获取python中的Form params的代码:

form = cgi.FieldStorage()

1 个答案:

答案 0 :(得分:0)

以下作品:

application:start(inets),                                                                                                                                                                  
Method = post,                                                                                                                                                                             
URL = "http://servername/cgi-bin/serverscript.py",                                                                                                                                     
Header = [],                                                                                                                                                                               
Type = "application/x-www-form-urlencoded",                                                                                                                                                
N = string:concat("from=", "fromemail"),                                                                                                                                        
P = string:concat("to=", "toemail"),                                                                                                                                          
Body = string:join([N, P], "&"),                                                                                                                                                           
HTTPOptions = [],                                                                                                                                                                          
Options = [],                                                                                                                                                                              
httpc:request(Method, {URL, Header, Type, Body}, HTTPOptions, Options).