Reputation: 2508
Windows 7 x64, Erlang-OTP 17.
I wrote simple module like this:
-module (somequery).
-export ([fbquery/2]).
fbquery(P1,P2) ->
inets:start(),
ssl:start(),
token = "78a8shd67tyajsndweiu03hr83h19j",
Encoded = {"Authorization","Basic " ++ base64:encode_to_string(lists:append([token,":",""]))},
ContentType = "application/xml",
Headers = [Encoded, {"Content-Type",ContentType}],
Options = [{body_format,binary}],
{ok, File}=file:read_file(P1),
Res = httpc:request(post, {"https://datapi.com/api/xml4-8", Headers, ContentType, File}, [], Options),
file:write_file(P2, io_lib:fwrite("~p.\n", [Res])).
This code working in interactive mode (werl.exe), and compiling into beam. The question is how use *.erl or compiled *.beam module now? How import it and run fbquery/2 method?
Upvotes: 0
Views: 169
Reputation: 380
First of, you need to add the directory containing your beam with the argument -pa Dir1 Dir2 ...
. It will add the directory to the erlang path and you will be able to type somequery:fbquery(Arg1,Arg2)
in your shell.
Then, you can use the argument -s module function [args..]
to launch erl with the specified function.
You can read about it in the erlang documentation for erl.
Upvotes: 1