开发者

Facebook API access outside of apps.facebook.com

开发者 https://www.devze.com 2023-03-12 21:48 出处:网络
I am attempting to build a website that utilizes facebook auth based setting created through facebook.com/developers

I am attempting to build a website that utilizes facebook auth based setting created through facebook.com/developers

Can I access a user’s wall (to post), mul开发者_开发百科ti friend selector and other elements if the website is hosted outside of facebook.com (apps.facebook.com) realm?


Yes, you need to use graph api through php sdk, js sdk or your own legacy one


You must require special permissions to post user's wall. Use a standard api mechanism to get access_token from user. Make sure user accepted the application permissions requirements such as offline_access, publish_stream etc.

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']; 
        }
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消