你可以讓erlang服務器發送一個帶有上述會話cookie的http請求到php服務器,並且如果session有效或沒有返回php服務器。 例如這裏是我通過recaptcha驗證網站的方式
-module(ed_recaptcha).
-license("GPL3").
-export([verify/4]).
-define(RECAPTCHA_URL, "http://api-verify.recaptcha.net/verify").
verify(Private_Key, Remote_Ip, Challenge, Response) ->
Body = list_to_binary(
io_lib:format(
"privatekey=~s&challenge=~s&response=~s&remoteip=~s",
[Private_Key, Challenge, Response, Remote_Ip])),
case http:request(post, {?RECAPTCHA_URL,
[], "application/x-www-form-urlencoded",
Body},
[{timeout, 30000}, {sync, false}],
[]) of
{ok, {_Status_line, _Headers, Response_Body}} ->
verify_response(Response_Body)
end.
verify_response("false\nincorrect-captcha-sol") ->
{error, robot};
verify_response("false\ninvalid-request-cookie") ->
{error, robot};
verify_response("true\nsuccess") ->
{ok, not_robot}.
來源
2009-06-18 20:48:43
mog