English 中文(简体)
利用Facebook图表显示无接触的图像取得公共网页状况
原标题:Get public page statuses using Facebook Graph API without Access Token

I m 试图利用Facebook图表普朗,从公共网页获得最新地位,请说

http://developers.facebook.com/tools/explorer/?method=GET&path=microsoft%2Fstatuses”rel=“noreferer” http://developers.facebook.com/tools/explorer/?method=GET&path=microsoft%2Fstatuses。 - 我需要打字。 由于微软网页是公开的,这无疑是这种情况吗? 难道我没有办法获得这些公共地位,没有机会得到证明?

如果是这样,那么如何为我的网站打造出入通道的正确方法? 然而,我有一份申请索引,但所有实例见:。 描述处理用户标识。 我只想获得微软网页的最新状况,并在我的网站上展示。

最佳回答

This is by design. Once it was possible to fetch the latest status from a public page without access token. That was changed in order to block unidentified anonymous access to the API. You can get an access token for the application (if you don t have a Facebook application set for your website - you should create it) with the following call using graph API:

https://graph.facebook.com/oauth/access_token?
client_id=YOUR_APP_ID&client_secret=YOUR_APP_SECRET&
grant_type=client_credentials  

这称为App Access Token。 然后,你使用从上述照相机进行实际的APIC电话。

希望这一帮助

问题回答

You can use AppID and Secret key to get the public posts/feed of any page. This way you don t need to get the access-token. Call it like below.

https://graph.facebook.com/PAGE-ID/feed?access_token=APP-ID|APP-SECRET

并且获得职位。

https://graph.facebook.com/PAGE-ID/posts?access_token=APP-ID|APP-SECRET

You can get the posts by simply requesting the site that your browser would request and then extracting the posts from the HTML.

在NodeJS,你可以这样做:

// npm i request cheerio request-promise-native
const rp = require( request-promise-native ); // requires installation of `request`
const cheerio = require( cheerio );

function GetFbPosts(pageUrl) {
    const requestOptions = {
        url: pageUrl,
        headers: {
             User-Agent :  Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:64.0) Gecko/20100101 Firefox/64.0 
        }
    };
    return rp.get(requestOptions).then( postsHtml => {
        const $ = cheerio.load(postsHtml);
        const timeLinePostEls = $( .userContent ).map((i,el)=>$(el)).get();
        const posts = timeLinePostEls.map(post=>{
            return {
                message: post.html(),
                created_at: post.parents( .userContentWrapper ).find( .timestampContent ).html()
            }
        });
        return posts;
    });
}
GetFbPosts( https://www.facebook.com/pg/officialstackoverflow/posts/ ).then(posts=>{
    // Log all posts
    for (const post of posts) {
        console.log(post.created_at, post.message);
    }
});

For more information and an example of how to retrieve more than 20 posts see: https://stackoverflow.com/a/54267937/2879085

我在数周内有类似的使用案例,我使用了该软件。

https://rapidapi.com/axesso/api/axesso-facebook-data-service/

I could fetch all posts and comments in some minutes, worked quite well for me.





相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Remotely authenticating client Windows user on demand

Suppose I am writing a server for a particular network protocol. If I know that the client is running on a Windows machine, is it possible for my server to authenticate the Windows user that owns the ...

Role/Permission based forms authorizing/authentication?

While looking into forms authorizing/authentication, I found that it is possible to do role based authorizing by adding an array of roles to a FormsAuthenticationTicket. That way I can write User....

热门标签