Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to detect if response is positive or negative on Facebook add friends dialog callback?
    primarykey
    data
    text
    <p>I'm adding <a href="https://developers.facebook.com/docs/reference/dialogs/friends/" rel="nofollow">Facebook's add friend dialog</a> to a User show page in a rails app.</p> <p>I've added the following code to the page</p> <pre><code>&lt;%= link_to "Friend on Facebook", "http://www.facebook.com/dialog/friends/?id=#{@user.facebook_uid}&amp;app_id=#{@my_app_id}&amp;redirect_uri=#{user_url(@user)}" %&gt; </code></pre> <p>So far so good, and I'm getting the following callback responses from Facebook:</p> <pre><code>If the user clicks to "Add Friend" (not sure where the additional # characters are coming from": http://myapp.com/user/1?action=1#_=_ If the user clicks "Cancel": http://myapp.com/user/1?action=0#_=_ </code></pre> <p>I want to detect these responses, and in the User controller have the following code</p> <pre><code>def show .... if params[:action] == 1 flash[:success] = "Friend added!" elsif params[:action] == 0 flash[:error] = "Not added" else flash[:notice] = "no message" end end </code></pre> <p>The Facebook callback is always dropping through the conditionals and generating the "no message" flash. I've tried various permutations, including converting to strings, integers, and adding the <code>#_=_</code> characters.</p> <p>If I render <code>&lt;%= params %&gt;</code> in the view I see </p> <pre><code>{"action"=&gt;"show", "controller"=&gt;"users", "id"=&gt;"5"} </code></pre> <p>but the url in the addressbar has the Facebook param</p> <pre><code>http://myapp.com/user/1?action=1#_=_ </code></pre> <p>While I'd like to find a fix for this, I'd also just like to understand what is happening. I would have assumed the action=1 would be added to the params response.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload