Fetch Facebook posts using Graph API

前端 未结 1 1573
失恋的感觉
失恋的感觉 2021-01-07 05:38

How to retrieve this information and show it in our website?

I\'ve tried this but no luck, please help.

1条回答
  •  忘掉有多难
    2021-01-07 06:02

    The problem is related to $.getJSON. As the documentation states, the request can not successfully retrieve data from a different domain, subdomain, or protocol.

    I don't see you mention a language you want to use in order to get those posts, but here are 2 simple examples of how to do it using:

    • PHP:

    $info = json_decode(file_get_contents('https://graph.facebook.com/cocacola/posts'));

    if ($info) {
        foreach ($info->data as $obj) {
            echo $obj->message, "
    "; } }
    • javascript:
    
    
    

    Good luck!

    0 讨论(0)
提交回复
热议问题