Note that there are some explanatory texts on larger screens.

plurals
  1. PODifficulty posting Actions to Timeline
    primarykey
    data
    text
    <p>I've tried building the basis of our next app following <a href="https://developers.facebook.com/docs/beta/opengraph/tutorial/" rel="nofollow">Facebook's Open Graph Tutorial</a> but for some reason I'm getting errors thrown at me regardless of how I try POSTing an action.</p> <p>I'll go as in-depth as I can here as I hope it'll be very useful for all developers getting to grips with the new Timeline.</p> <p>I've defined a <strong>battle</strong> action and a <strong>hero</strong> object using the default settings when setting up each. <strong>transcendgame</strong> is my namespace.</p> <p><code>$id</code> is the userid of the Facebook user (I've tried using /me/, the direct id has always been less problematic in the past for me).</p> <p><code>$herourl</code> is an urlencoded string pointing to a separate webpage with the following content:</p> <pre class="lang-html prettyprint-override"><code> &lt;head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# transcendgame: http://ogp.me/ns/fb/transcendgame#"&gt; &lt;meta property="fb:app_id" content="[my id]"&gt; &lt;meta property="og:type" content="transcendgame:hero"&gt; &lt;meta property="og:url" content="http://apps.facebook.com/transcendgame/"&gt; &lt;meta property="og:title" content="Hercules"&gt; &lt;meta property="og:description" content="As this game is still in development, you can ignore this feed post!"&gt; &lt;meta property="og:image" content="[an image url]"&gt; </code></pre> <p>The application canvas page contains the following code. It should POST a new action event to the user's timeline, but is consistently giving me "Error occured". I have also tried it with the sample hero object (samples.ogp.me...) with the same problem.</p> <pre><code>&lt;script&gt; function doTest() { FB.api('/&lt;?=$id?&gt;/transcendgame:battle' + '?hero=&lt;?=$herourl?&gt;','post', function(response) { if (!response || response.error) { alert('Error occured'); } else { alert('Post was successful! Action ID: ' + response.id); } }); } &lt;/script&gt; &lt;a href="#" onclick="doTest(); return false"&gt;Test fb post&lt;/a&gt; </code></pre> <p>I'm calling the JS SDK and running fb.init correctly. I honestly don't know where the problem even lies, let alone how to fix it.</p> <p><strong>EDIT:</strong> I've correctly added the user's access token to the API call:</p> <pre><code>FB.api('/me/transcendgame:battle' + '?hero=&lt;?=$herourl?&gt;&amp;access=&lt;?=$token?&gt;','post', </code></pre> <p>However, I'm getting the following error:</p> <pre><code>Type: OAuthException Message: (#3502) Object at URL [url] has og:type of 'game'. The property 'hero' requires an object of og:type 'transcendgame:hero'. </code></pre> <p>This is odd, as the webpage definitely does have og:type set correctly, as listed earlier in this question. Is this some Facebook hiccup I need to work around?</p> <p><strong>SECOND EDIT</strong>: Fixed the final problem.</p> <p>The <strong>og:url</strong> I had assumed to point back to the URL of the app's canvas, but it needs to reference <em>itself</em> instead. For instance, if your object is on mydomain.com/object1.php then the code must be:</p> <pre><code>&lt;meta property="og:url" content="http://www.mydomain.com/object1.php"&gt; </code></pre> <p>Hope this helps others.</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.
 

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