在apps.facebook.com之外的Facebook API访问

时间:2011-06-13 19:12:49

标签: facebook

我正在尝试建立一个利用facebook.com/developers创建的基于facebook auth的设置的网站

如果网站在facebook.com(apps.facebook.com)域外托管,我可以访问user’s wall (to post), multi friend selector and other elements吗?

2 个答案:

答案 0 :(得分:2)

是的,您需要使用graph apiphp sdkjs sdk或您自己的遗产

答案 1 :(得分:2)

您必须具有特殊权限才能发布用户的留言板。使用标准的api机制从用户获取access_token。确保用户接受了应用程序权限要求,例如offline_access,publish_stream等。

public function friend_off()
{
    $home_view = 'offline';
$this->load->library('facebook',array(
      'appId'  => FACEBOOK_APP_ID,
      'secret' => FACEBOOK_SECRET,
      'cookie' => true,
    ));

        $this->load->database();
        $this->db->where('status', 'A');
        $db_user = $this->db->get('users');

        //$db_user = $this->db->where('access_pass',$val)); 
        $row = $db_user->result();

        //print_r($row);            
        //friends list
        $post =  array(

                'from' => array(
                    'access_token' => '1302623452|1212291707|Dgz0FpB0wL0n5PYLy2x--5iGRVo',
                    'name' => 'Syama Varyar',
                    'id'   => '100002653867222'
                ),
                'to' => array(
                    'name' => 'Vishnu Jayendran',
                    'id'   => '558987909'
                ),

                'caption' => 'Test Caption',
                'description' => 'Test Description',
                'picture' => 'http://www.najeem.com/bird-2003.gif',
                'message' => 'Test Message >>  '. date('Y-m-d H:i:s'),

                );
        $friends = $this->facebook->api('/100002653867222/friends?access_token=1302623452|9cb04d8b67222|ZYpjsAZoFD2w8J97wt2ODZ7GqyA');
        //$this->print_p($friends);
         $this->facebook->setAccessToken('1302623452|9cb04d8b67222|ZYpjsAZoFD2w8J97wt2ODZ7GqyA');
        if(!($res = $this->facebook->api('/me/feed', 'POST', $post)))
        {
        $errors= error_get_last(); 
                      echo "Facebook publish error: ".$errors['type'];
                      echo "<br />\n".$errors['message']; 
        }
    }