Facebook graph api photo upload to a fan page album

后端 未结 2 479
迷失自我
迷失自我 2021-01-05 06:17

I have gotten the photo upload function to work with this code,



        
相关标签:
2条回答
  • 2021-01-05 06:38

    This seems to be a bug with the Graph API. See this http://forum.developers.facebook.com/viewtopic.php?id=59063 (can't post links, yet)

    0 讨论(0)
  • 2021-01-05 06:42

    Follow the simple Get login url with

    $data['url'] = $this->facebook->getLoginUrl(array('scope'=>'publish_stream,read_stream,user_likes,user_photos,manage_pages'));

    this will let you post photo and add album in fanpage. Get access token for

    $accounts = $this->facebook->api('/'.$PAGE_ID.'?fields=access_token', 'get', array('access_token' => $access_token));
    $page_access_token = $accounts['access_token'];
    

    Create album with other detail

                $album_details = array(
                     'message'=> 'Test album',
                   'name'=> $today ,//should be unique each time,
                'access_token'=>$page_access_token
                );
                $album_created = $this->facebook->api('/'.$PAGE_ID.'/albums', 'post', $album_details);
    

    Upload photo to a particualar fanpage album

    $photo = $this->facebook->api('/'.$album_id.'/photos', 'POST', array(
                                             'source' => "@"."@".realpath(BASEPATH."../".$photopath),
                                             'message' => 'new photo',
                            'access_token' => $page_access_token,
                            'no_story' => 0
                                             )
                                          );
    
                    //print_r( $album_created['id'] );
    

    And change the path as you wish Happy coding

    This code works aweesome in this site....why downvoted.?You can post photos to fanpage if you are owner of that page.I have a working copy of that application.

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