简体   繁体   中英

Getting private posts from my Facebook wall

First off: I googled and tried complete a day but only running circles. When searching google for my problem I got plenty forum-posts and articles which seem to be described the same way as I would describe my problem. But their solution goes another way.

So what I actually want to do is very easy:

Most of my Status Posts on Facebook are private for stared friends only but some of these posts go out to all my friend because they are some kinda fuzzy blog posts which are totally insensitive so I don't care if the public may see them.

Well. I got a self written PHP Homepage which I would like to print some of the posts I've written on my Facebook-wall. These posts are not public on Facebook but shall be printed (in filtered form) on my Homepage.

That's all. I can't get this to work (fetching posts).

I tried the api explorer (fb-dev-tool) to see how the access tokens work and just tried to use the generated token. Works fine... for an hour, till the token expires...

So I found blog posts telling me to create a private facebook app.

I did so, but this App is only allowed to read my profiles public data... stuff like posts to public walls (of other people or companies) or public likes...

I now don' even know if creating a app was the right way for my purpose but user access tokens (which seem to be the right point for solving my problem) seem to always expire after ~one hour.

So if using an app would be the right way, I need to know how to associate my profile with this (own) app or grant the rights to access the private wall posts.

Most solutions seem to involve the user who is viewing the api-using page to forfill actions like "show me the posts of your wall!" or something. But of course that's not what I need. For my purpose the visitor does not even need to have a facebook account.

[...]

What I tried:

  • I tried the api exlorer to understand how the stuff works. I mean. Even the api explorer is a app (written by facebook) which can easily get access to my private data
  • I tried using api explorer generated key -> they expire
  • I tried using the offical PHP facebook api:

    $facebook = new Facebook(array( 'appId' => 'myAppId', 'secret' => 'mySecret' ));

    $foo = $facebook->api('/myprofileid/posts'); // -> only gets the public stuff

  • I tried using a "self made" app to access data of my profile

All of these tries failed in non-understanding how that api and data stuff works and sticks together...

So the question is: How do I get the toke / the app to fetch private data from my profile? Or: What would be the right way to get this data?

Thanks ahead!

You will need to extend the expiry of your access tokens to be able to do this and then store the long-term token in a database. Here are 2 pages(sections) that should help with this:

https://developers.facebook.com/docs/facebook-login/access-tokens/#termtokens

https://developers.facebook.com/docs/facebook-login/access-tokens/#extending

Here is some info on extending the token:

GET /oauth/access_token?  
    grant_type=fb_exchange_token&           
    client_id={app-id}&
    client_secret={app-secret}&
    fb_exchange_token={short-lived-token} 

You will still want to extend your tokens periodically because they expire in ~60 days.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM