Tiliman’s Weblog

January 2, 2013

Google Cloud Messaging with Erlang

I have been working on Facebook matchmaking code for Android/Unity to mimic iOS Game Center like flow of match making where other player receives notification on phone. Server side is coded with Mochiweb in Erlang. Here is simple code to send GCM Notification.

 

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
send_gcm_msg(ApiKey, Pnstoken, Message, Game) ->
        Baseurl = "http://android.googleapis.com/gcm/send",
        ApiKey1 = string:concat("key=",ApiKey),
        %% Create Json struct
        Body = lists:flatten(mochijson:encode({struct, [{registration_ids,{array, [Pnstoken]}},
                        {data,{struct, [{message,Message},{game,Game}]}},
                        {time_to_live,3600},
                        {collapse_key,game_invite}]})),
        try httpc:request(post, {Baseurl,[{"Authorization",ApiKey1}],"application/json",Body},[],[]) of
                {ok, {{_,200,_},_,RespBody}} ->
                        {ok, mochijson:decode(RespBody)};
                {error, Reason } ->
                        {error, Reason};
                {ok, {{StatusLine,_,_},_,RespBody}} ->
                        {error, {StatusLine, RespBody}};
                BigError -> {error, BigError}
        catch
                Throw -> {error, caught, Throw}
        end.

November 9, 2009

Posssible Privacy bug in Facebook?

Filed under: Facebook — tiliman @ 7:07 pm

 

Today I was browsing through list of friends of one of my friends (Friend_A). I found a profile of another person (Person_A). I wanted to view his pictures but his privacy settings didn’t allow viewing his albums/pictures. I couldn’t see Photos tab on profile page.

Later my friend (Friend_A) sent a link to (Person_A)’s picture on facebook and I was able to view it using that link. I was able to go through his albums completely without any issue.

I sent the same link to my another friend and he was able to view all pictures too even though he was not even 2nd level link to that person.

Is this possibly a bug in Facebook?

Blog at WordPress.com.