title: How do I publish to Timeline Automatically?
body: <p><a href="http://www.independent.co.uk/" rel="nofollow noreferrer">http://www.independent.co.uk/</a> and <a href="http://www.guardian.co.uk/" rel="nofollow noreferrer">http://www.guardian.co.uk/</a> have an application where by if you read an article on their site, it writes to your profile/timeline that &quot;X has read Y on Z&quot;.</p>
  <p>Now I can write to the timeline with a button present. I can also do it automatically (but this happens each time they go to the article which I don't need). However what I need to add is some logic as shown below</p>
  <ol>
  <li>If user logged in but app not authorised
  <ul>
  <li>Show a button to authorise application</li>
  </ul>
  </li>
  <li>If user logged in and app authorised and visiting article for first time
  <ul>
  <li>Automatically publish &quot;X has read Y on Z&quot; to their profile and FB</li>
  </ul>
  </li>
  <li>If user logged in and app authorised and visiting article again
  <ul>
  <li>Don't publish anything</li>
  </ul>
  </li>
  </ol>
  <p>Does this make sense? Any examples of this around? So basically pulishing to the timeline isn't an issue, it's just the various checks I need to put into place.</p>
  <p><strong>EDIT</strong></p>
  <p>Ok, for some reason this works (for checking of they are authorised or not) but if I take out the <code>alert('test');</code> part, it doesn't work. Any ideas?</p>
  <pre><code>&lt;script&gt;(function(d, s, id) {
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) {return;}
    js = d.createElement(s); js.id = id;
    js.src = &quot;//connect.facebook.net/en_GB/all.js#xfbml=1&amp;appId=123456789&quot;;
    fjs.parentNode.insertBefore(js, fjs);
  }(document, 'script', 'facebook-jssdk'));
  
  alert('test');
  
      FB.init({ 
          appId:'123456789', cookie:true, 
          status:true, xfbml:true, oauth:true
      });
      
  FB.getLoginStatus(function(response) {
    if (response.status === 'connected') {
      var uid = response.authResponse.userID;
      var accessToken = response.authResponse.accessToken;
      alert('Logged in and connected');
      $(read);
    } else if (response.status === 'not_authorized') {
      alert('Logged into FB but not authorised');
    } else {
      alert('Not logged into FB');
    }
  });
  &lt;/script&gt;
  </code></pre>
  <hr />
  <p>Ok, got it partly working. There are some slight niggles but main issue now is to check whether they have posted a specific action to the timeline already. If they have then don't post another e.g. So when they go to an article first time, the status &quot;Jon has read an article on the Site&quot; gets added. However if they go to it again, it doesn't get added</p>