Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>At first I just went into the Facebook Application settings and re-enabled the deprecated "offline access" permission. Said application settings can be found at a URL like this:</p> <pre><code>https://developers.facebook.com/apps/{APPLICATION_ID}/advanced </code></pre> <p>However, since everything keeps referring to that setting as being "deprecated" then I didn't want to use that as a long-term solution. It may get removed entirely, it may be unsafe in certain circumstances, etc. Better to use recommended functionality.</p> <p>So here's what I was able to piece together from a scavenger hunt through updated documentation, outdated documentation, a sea of outdated internet posts, and PHP code which mostly made assumptions about functionality that aren't true in all cases...</p> <p>Visit the <a href="https://developers.facebook.com/tools/explorer" rel="noreferrer">Graph API Explorer</a> and select your Facebook Application from the drop-down menu. Click "Get Access Token" and select the permissions you want. (For mine I went to the "Extended Permissions" tab and selected "Managed Pages" and "Publish Stream.") You will be prompted (in my browser it was in a new tab) with a familiar screen where the Facebook Application is asking you, the user, to grant it the permissions you just selected. (You've seen this before if you've ever agreed to use a Facebook Application before.)</p> <p>The value it produces in the Graph API Explorer (a long string of random-ish characters) is your "Short Lived User Access Token."</p> <p>As described <a href="https://developers.facebook.com/roadmap/offline-access-removal" rel="noreferrer">here</a> in "Scenario 4: Client-side OAuth and Extending Access_Token Expiration Time through New Endpoint" access this URL in your web browser:</p> <pre><code>https://graph.facebook.com/oauth/access_token? client_id={APPLICATION_ID} &amp;client_secret={APPLICATION_SECRET} &amp;grant_type=fb_exchange_token &amp;fb_exchange_token={SHORT_LIVED_USER_ACCESS_TOKEN} </code></pre> <p>(You can obtain the <code>{APPLICATION_SECRET}</code> value on the basic settings page for your Facebook Application: <code>https://developers.facebook.com/apps/{APPLICATION_ID}/summary</code>)</p> <p>This will return another Access Token as such:</p> <pre><code>access_token={LONG_LIVED_USER_ACCESS_TOKEN}&amp;expires=5184000 </code></pre> <p>This <code>access_token</code> value (another long string of random-ish characters) is your "Long Lived User Access Token." The <code>expires</code> value is in seconds, which translates into 60 days.</p> <p>Now we hop over to the <a href="https://developers.facebook.com/docs/reference/api/page" rel="noreferrer">Page API reference</a> and take a look at the section on <a href="https://developers.facebook.com/docs/reference/api/page/#page_access_tokens" rel="noreferrer">Page Access Tokens</a>. This, along with the basic structure of Graph API requests exemplified <a href="https://developers.facebook.com/docs/reference/api/" rel="noreferrer">here</a> (scroll down to the part where it shows a bulleted list of sample links which include <code>access_token</code> specifiers, which you'll need to specify here because you're requesting non-public information) leads you to request this in your browser:</p> <pre><code>https://graph.facebook.com/{FACEBOOK_USER_ID}/accounts? access_token={LONG_LIVED_USER_ACCESS_TOKEN} </code></pre> <p>This will return a JavaScript object containing lots of useful information about the Facebook Pages and Facebook Applications your user account controls. In my case the Page and the Application had the same name, but it's easy to tell them apart from the <code>category</code> values or, if all else fails, the <code>id</code> values. Find the Page that the background application running on your machine will need to access and copy its <code>access_token</code> (the third and final long string of random-ish characters). The whole node looks something like this:</p> <pre><code>{ "name": "Some Facebook Application Name", "access_token": "{LONG_LIVED_PAGE_ACCESS_TOKEN}", "category": "Musician/band", "id": "{APPLICATION_ID}", "perms": [ "ADMINISTER", "EDIT_PROFILE", "CREATE_CONTENT", "MODERATE_CONTENT", "CREATE_ADS", "BASIC_ADMIN" ] } </code></pre> <p>This is your "Long Lived Page Access Token." This is the value you use to initialize the FacebookClient object in the code. Then, posting a simple status update is as easy as:</p> <pre><code>var client = new FacebookClient("{LONG_LIVED_PAGE_ACCESS_TOKEN}"); dynamic parameters = new ExpandoObject(); parameters.message = "This is a my status update."; dynamic result = client.Post("{FACEBOOK_PAGE_ID}/feed", parameters); </code></pre> <p>Supposedly this "Long Lived Page Access Token" does <em>not</em> expire after 60 days like the "Long Lived User Access Token" does. I'll find out in 59 days, I guess.</p> <hr /> <p>NB: The curly braces in my examples are part of the placeholder for actual values. Do not use the curly braces in the actual requests. So something like this:</p> <pre><code>https://developers.facebook.com/apps/{APPLICATION_ID}/advanced </code></pre> <p>becomes something like this, for example:</p> <pre><code>https://developers.facebook.com/apps/123456/advanced </code></pre> <p>where <code>123456</code> is the actual Facebook Application ID.</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. 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.
    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