Note that there are some explanatory texts on larger screens.

plurals
  1. POFacebook retrieve correct acess_tokens
    primarykey
    data
    text
    <p>I am having trouble finding the right access_tokens. I have tried all ways that I have found on Google and developers.fb, but for this application(I have done it before, and made it work for another app) I just don't seem to be succesful.</p> <p>I am aware that FB is constantly renewing their API's so maybe I just have found outdated solutions. </p> <p>There seem to be different types of access tokens: user access tokens, and page access tokens. I find some answers in facebook documentation, but none that I understand.</p> <p>The app I'm trying to create is something similar to a birthday-reminder, so it needs to be able to send offline messages(fex. be runned by a cron-job, and post to just one fb-page, owned by me, just in the name of the app itself)</p> <p>I have registered the app with the page-tab on this address: --<code>https://www.facebook.com/dialog/pagetab?app_id=MY_APP'S_ID&amp;display=popup&amp;next=MY_URL</code>-- and can now find it from the Facebook-page's settings.</p> <p>Then I get to the part where i need the access token. I dont know which of the URL's that give me what kind of access token, so I have tried both:</p> <p>I have visited this URL: (I write all links duplicate, the answer from tutorials, and my re-written link) (of course all code pointing to my app and webpage is replaced for security reasons)</p> <p>--<code>https://www.facebook.com/dialog/oauth?client_id=0123456789011121&amp;redirect_uri=http://www.example.com&amp;scope=read_stream,publish_stream,offline_access</code>--</p> <p>--<code>https://www.facebook.com/dialog/oauth?client_id=MY_APP_ID&amp;redirect_uri=MY_REDIRECT_URL&amp;scope=read_stream,publish_stream,offline_access</code>--</p> <p>and got:</p> <pre><code>http://www.example.com/?code=XXXXX1x1X1xxXxxX1xXxXxX1X111xX11XXXXX1XXXXXxX_XxXxxXxX1xxxXx1xXxXx-x1XxXXXxXXx1xXxXXXxXl1xX-111xXxxxXxxx1xXxxx1xXx1X1X1Xx-xxxXXXxXXXX1XXXXxx1Xxx1_xXxXxxxXx1x1XxXxxXx1XXxX-x1x1xxxXXxXxX1XX1XX1x1-xxXxxxx1Xx1XxXXXxxX#_=_ </code></pre> <p>in other words(as I believe), retrieved the code:</p> <pre><code>XXXXX1x1X1xxXxxX1xXxXxX1X111xX11XXXXX1XXXXXxX_XxXxxXxX1xxxXx1xXxXx-x1XxXXXxXXx1xXxXXXxXl1xX-111xXxxxXxxx1xXxxx1xXx1X1X1Xx-xxxXXXxXXXX1XXXXxx1Xxx1_xXxXxxxXx1x1XxXxxXx1XXxX-x1x1xxxXXxXxX1XX1XX1x1-xxXxxxx1Xx1XxXXXxxX#_=_ </code></pre> <p>As I have found on Google, it seems as I need to get another code as well, so then I have visited this URL(of course I have tried the first code I got first):</p> <pre><code>https://graph.facebook.com/oauth/access_token?client_id=0123456789011121&amp;redirect_uri=http://www.example.com&amp;client_secret=1x1111xx11111xXXx11x111111111x11&amp;code=XXXXX1x1X1xxXxxX1xXxXxX1X111xX11XXXXX1XXXXXxX_XxXxxXxX1xxxXx1xXxXx-x1XxXXXxXXx1xXxXXXxXl1xX-111xXxxxXxxx1xXxxx1xXx1X1X1Xx-xxxXXXxXXXX1XXXXxx1Xxx1_xXxXxxxXx1x1XxXxxXx1XXxX-x1x1xxxXXxXxX1XX1XX1x1-xxXxxxx1Xx1XxXXXxxX#_=_ </code></pre> <p>--<code>https://graph.facebook.com/oauth/access_token?client_id=MY_APP_ID&amp;redirect_uri=MY_REDIRECT_URL&amp;client_secret=MY_APP_SECRET&amp;code=THE_CODE_I_GOT_FROM_THE_PREVIOUS_RUN</code>--</p> <p>But when i try to run the app I get this error message: Result: <code>{"error":{"message":"Malformed access token XXXXX1x1X1xxXxxX1xXxXxX1X111xX11XXXXX1XXXXXxX_XxXxxXxX1xxxXx1xXxXx-x1XxXXXxXXx1xXxXXXxXl1xX-111xXxxxXxxx1xXxxx1xXx1X1X1Xx-xxxXXXxXXXX1XXXXxx1Xxx1_xXxXxxxXx1x1XxXxxXx1XXxX-x1x1xxxXXxXxX1XX1XX1x1-xxXxxxx1Xx1XxXXXxxX#_=_","type":"OAuthException","code":190}}</code></p> <p>I have tried with different types of the ending of the access token(#<em>=</em>), because I dont recognize it from the other, working access token I retrieved last week, to a fully working app that I have built. That one did not have that ending, as I remember.</p> <p>I also post the script here, if that is of any interest. I have found it in a tutorial, and it is quite simple code:</p> <pre><code>&lt;?php // CURL function to send with post method function send_post_curl($url, $postdata = “”) { $ch = curl_init($url); curl_setopt ($ch, CURLOPT_POST, 1); curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); $data = curl_exec ($ch); curl_close ($ch); return $data; } // setup the message $fburl = 'https://graph.facebook.com/THE_FB_PAGE_ID/feed'; $fbtoken = 'THE_ACCESS_TOKEN'; $fbmsg = 'Great API to auto status, this is the message. Thank to WebDDR http://webddr.net/tips-and-tricks/facebook-offline-access-step-by-step-explanation/'; $fbpcurl = 'access_token='. $fbtoken; $fbpcurl .= '&amp;message='. str_replace('&amp;', 'and', urlencode($fbmsg)) ; $result = send_post_curl($fburl, $fbpcurl); echo 'Result: '. $result; ?&gt; </code></pre> <p>I really hope someone can help me, I am doing this as an job I have choosen to do for my education at the university. /Johan PS. Sorry, had to wrangle with the links, --link-- because the forum thought it was spam Ds.</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.
 

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