如何通过应用程序以管理员身份在facebook上共享链接


how to sharelink on facebook as admin via an application?

如何通过应用程序以管理员身份在facebook页面上共享链接?

示例:类似tihs

花了大约2个小时为您解决这个问题。高兴;)

require_once("facebook.php");
    $facebook = new Facebook(array(
        'appId'  => 'YOUR APP ID',
        'secret' => 'YOUR APP SECRET',
    ));
    $pageID = 123456789; //YOUR PAGE ID HERE
    $user_id = $facebook->getUser();
    if($user_id != false && $user_id != 0) {
        //user is logged in.
        $response = $facebook->api('me/accounts');
        foreach ($response['data'] as $key => $val) {
            if ($val['id'] == $pageID) {
                $page_access_token = $val['access_token'];
                //Below is the API Call for the posting to the page's wall.
                $api = $facebook->api('me/feed', 'POST', array('message' => 'LOLs', 'access_token' => $page_access_token)); 
            }
        }
     }
     else { 
        //if user is not logged in, make them log in.
        header('location:' . $facebook->getLoginURL(array('scope' => 'publish_stream, manage_pages')));
     }