|
@@ -8,41 +8,40 @@
|
|
-compile(export_all).
|
|
-compile(export_all).
|
|
-export(?API).
|
|
-export(?API).
|
|
|
|
|
|
--define(HTTP_ADDRESS, case application:get_env(web, http_address) of {ok, A} -> A; _ -> "" end).
|
|
|
|
--define(FB_APP_ID, case application:get_env(web, fb_id) of {ok, Id} -> Id; _-> "" end).
|
|
|
|
--define(FB_BTN_CLASS, case application:get_env(web, fb_btn_class) of {ok, C} -> C; _ -> "btn-primary btn-large btn-lg" end).
|
|
|
|
--define(FB_BTN_BODY, case application:get_env(web,fb_btn_body) of {ok, _FBBTNBODY} -> _FBBTNBODY; _ -> [#i{class=[fa,"fa-facebook","fa-lg","icon-facebook","icon-large"]}, <<"Facebook">>] end).
|
|
|
|
|
|
+-define(HTTP_ADDRESS, application:get_env(web, http_address, [])).
|
|
|
|
+-define(FB_APP_ID, application:get_env(web, fb_id, [])).
|
|
|
|
|
|
callback() -> ok.
|
|
callback() -> ok.
|
|
event({facebook,_Event}) -> wf:wire("fb_login();"), ok.
|
|
event({facebook,_Event}) -> wf:wire("fb_login();"), ok.
|
|
-api_event(fbLogin, Args, _Term)-> JSArgs = n2o_json:decode(Args), avz:login(facebook, JSArgs#struct.lst).
|
|
|
|
|
|
+api_event(fbLogin, Args, _Term) -> JSArgs = n2o_json:decode(Args), avz:login(facebook, JSArgs#struct.lst).
|
|
|
|
|
|
registration_data(Props, facebook, Ori)->
|
|
registration_data(Props, facebook, Ori)->
|
|
Id = proplists:get_value(<<"id">>, Props),
|
|
Id = proplists:get_value(<<"id">>, Props),
|
|
BirthDay = case proplists:get_value(<<"birthday">>, Props) of
|
|
BirthDay = case proplists:get_value(<<"birthday">>, Props) of
|
|
undefined -> {1, 1, 1970};
|
|
undefined -> {1, 1, 1970};
|
|
BD -> list_to_tuple([list_to_integer(X) || X <- string:tokens(binary_to_list(BD), "/")]) end,
|
|
BD -> list_to_tuple([list_to_integer(X) || X <- string:tokens(binary_to_list(BD), "/")]) end,
|
|
-% error_logger:info_msg("User Ori: ~p",[Ori]),
|
|
|
|
-% error_logger:info_msg("Props: ~p",[Props]),
|
|
|
|
Email = email_prop(Props, facebook),
|
|
Email = email_prop(Props, facebook),
|
|
[UserName|_] = string:tokens(binary_to_list(Email),"@"),
|
|
[UserName|_] = string:tokens(binary_to_list(Email),"@"),
|
|
Cover = case proplists:get_value(<<"cover">>,Props) of undefined -> ""; P -> case proplists:get_value(<<"source">>,P#struct.lst) of undefined -> ""; C -> binary_to_list(C) end end,
|
|
Cover = case proplists:get_value(<<"cover">>,Props) of undefined -> ""; P -> case proplists:get_value(<<"source">>,P#struct.lst) of undefined -> ""; C -> binary_to_list(C) end end,
|
|
Ori#user{ id = Email,
|
|
Ori#user{ id = Email,
|
|
display_name = UserName,
|
|
display_name = UserName,
|
|
- images = avz_userhelper:updateProplist({fb_cover,Cover},avz_userhelper:updateProplist({fb_avatar,"https://graph.facebook.com/" ++ binary_to_list(Id) ++ "/picture?type=large"},Ori#user.images)),
|
|
|
|
|
|
+ images = avz:update({fb_cover,Cover},avz:update({fb_avatar,"https://graph.facebook.com/" ++ binary_to_list(Id) ++ "/picture?type=large"},Ori#user.images)),
|
|
email = Email,
|
|
email = Email,
|
|
names = proplists:get_value(<<"first_name">>, Props),
|
|
names = proplists:get_value(<<"first_name">>, Props),
|
|
surnames = proplists:get_value(<<"last_name">>, Props),
|
|
surnames = proplists:get_value(<<"last_name">>, Props),
|
|
- tokens = avz_userhelper:updateProplist({facebook,Id},Ori#user.tokens),
|
|
|
|
|
|
+ tokens = avz:merge({facebook,Id},Ori#user.tokens),
|
|
birth = {element(3, BirthDay), element(1, BirthDay), element(2, BirthDay)},
|
|
birth = {element(3, BirthDay), element(1, BirthDay), element(2, BirthDay)},
|
|
- register_date = erlang:now(),
|
|
|
|
|
|
+ register_date = os:timestamp(),
|
|
status = ok }.
|
|
status = ok }.
|
|
|
|
|
|
email_prop(Props, _) ->
|
|
email_prop(Props, _) ->
|
|
proplists:get_value(<<"email">>, Props).
|
|
proplists:get_value(<<"email">>, Props).
|
|
|
|
|
|
-login_button() ->
|
|
|
|
- #panel{class=["btn-group"], body=#link{id=loginfb, class=[?FB_BTN_CLASS],body=?FB_BTN_BODY, postback={facebook,loginClick} }}.
|
|
|
|
|
|
+login_button() -> application:get_env(avz,facebook_button,
|
|
|
|
+ #panel{class=["btn-group"], body=#link{id=loginfb,
|
|
|
|
+ class=["btn-primary btn-large btn-lg"],
|
|
|
|
+ body=[#i{class=[fa,"fa-facebook","fa-lg","icon-facebook","icon-large"]},
|
|
|
|
+ <<"Facebook">>], postback={facebook,loginClick} }}).
|
|
|
|
|
|
sdk() ->
|
|
sdk() ->
|
|
wf:wire(#api{name=setFbIframe, tag=fb}),
|
|
wf:wire(#api{name=setFbIframe, tag=fb}),
|