2017-04-23 71 views

回答

0

我已經使用這個:

spawn(mod_http_offline, http_request, [Url, Post]). 

    % Function that make a call 
    http_request(Url, Post)-> 
     TypeData = "application/x-www-form-urlencoded", 
     Header = [], 
     HTTPOptions = [], 
     Options = [], 
     httpc:request(post, {Url, Header, TypeData,list_to_binary(Post)}, HTTPOptions, Options). 

但是當我編譯,得到這樣的:

Warning: function http_request/2 is unused

和功能不叫

+1

您需要導出該函數以便全局調用它(這是使用spawn/3時的情況)。 P.S:您可以通過在選項中添加{sync,false}來在httpc中使用異步呼叫。在此處查看示例http://www1.erlang.org/doc/apps/inets/http_client.html#id60384 –