Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Have you tried adding the <em>display</em> parameter, like so:</p> <pre><code>var obj = { method: 'feed', link: 'http://www.facebook.com/testapp/app_myappid/', picture: 'http://fbrell.com/f8.jpg', name: 'Facebook Dialogs', caption: 'Reference Documentation', description: 'Using Dialogs to interact with users.', display: 'iframe' }; ... FB.ui(obj, callback); </code></pre> <p>Reference: <a href="https://developers.facebook.com/docs/reference/dialogs/" rel="noreferrer">https://developers.facebook.com/docs/reference/dialogs/</a></p> <hr> <h1>Edit</h1> <p>As it says in the same document I posted:</p> <blockquote> <p>If you specify iframe, you must have a valid access_token.</p> </blockquote> <p>Looking at your code, you did seem to skip the authentication process. You see, you can't just call <em>FB.init</em> and then start using the api, you need to ask the SDK to authenticate the user.</p> <p>There are some ways to do so, you should check the <a href="http://developers.facebook.com/docs/authentication/client-side/" rel="noreferrer">Client-Side Authentication</a> document for more info. Here's your modified code, I added the use of the <a href="http://developers.facebook.com/docs/reference/javascript/FB.login/" rel="noreferrer">FB.login</a> method of the SDK, and it states that:</p> <blockquote> <p>Calling FB.login results in the JS SDK attempting to open a popup window. As such, this method should only be called after a user click event, otherwise the popup window will be blocked by most browsers.</p> </blockquote> <p>So you might need to authorize this popup for it to work, you should in reality use another approach (as discussed in that client side auth doc) or just call this method after a user clicked something. This is just to give you a nudge to the right direction:</p> <pre><code>function callback(response) { document.getElementById('msg').innerHTML = "Post ID: " + response['post_id']; } function postToFeed() { // calling the API ... var obj = { method: 'feed', link: 'http://www.facebook.com/testapp/app_myappid/', picture: 'http://fbrell.com/f8.jpg', name: 'Facebook Dialogs', caption: 'Reference Documentation', description: 'Using Dialogs to interact with users.', }; FB.ui(obj, callback); } FB.init({ appId: "myappid", status: true, cookie: true }); FB.login(function(response) { if (response.authResponse) { postToFeed(); } else { alert("user NOT logged in"); } }); </code></pre> <hr> <h1>2nd Edit</h1> <p>Since it's a canvas app, and you would like to avoid the login popup, there's another solution.</p> <p>If you get that error message it means that you're (probably) missing a client side auth, you can pass along the access token you have from the server side and use it in the client, or you can do something like this:</p> <pre><code>window.fbAsyncInit = function() { FB.init({ appId: "myappid", status: true, cookie: true }); FB.getLoginStatus(function(response) { if (response.status === "connected") { postToFeed(); } else { console.log("not logged in to facebook or hasn't authorized the app"); } }; }; function postToFeed() { // calling the API ... var obj = { method: 'feed', link: 'http://www.facebook.com/testapp/app_myappid/', picture: 'http://fbrell.com/f8.jpg', name: 'Facebook Dialogs', caption: 'Reference Documentation', description: 'Using Dialogs to interact with users.', }; function callback(response) { document.getElementById('msg').innerHTML = "Post ID: " + response['post_id']; } FB.ui(obj, callback); } </code></pre> <p>This won't open a popup or anything of that sort, and will just check the user login status. You can read more about the <a href="http://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus/" rel="noreferrer">FB.getLoginStatus</a> method.</p> <p>Also, I recommend using the <a href="http://developers.facebook.com/docs/reference/javascript/" rel="noreferrer">Channel File</a> parameter when initializing the js sdk. It should not make any difference in this case, but it's safer.</p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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