Facebook粉丝页面封面图片更改

时间:2013-06-28 09:32:34

标签: facebook api

我期待使用php和facebook sdk开发应用程序,以便我可以更改粉丝页面的封面图片。

我是我创建的应用程序的管理员,并使用相同的appId和appSecret。

我在这里发布我的源代码,任何帮助都将不胜感激。

它抛出异常“Uncaught OAuthException:(#10)Application没有此操作的权限”

    require 'php-sdk/facebook.php';
    $app_id = "My App ID";
    $app_secret = "My App Secret";
    $post_login_url = "URL";


    $facebook = new Facebook(array(
      'appId'  => $app_id,
      'secret' => $app_secret,
      'cookie' => true
    ));


    $user_fb = $facebook->getUser();

    if($user_fb == 0)
    {
        $user_fb = $facebook->getUser();
    }

    if ($user_fb) 
    {   
        $user_profile = $facebook->api('/me'); 
        $user_friends = $facebook->api('/me/friends'); 
        $logoutUrl = $facebook->getLogoutUrl(); 

    }
    else 
    {     
         $perms = array('scope' => 'user_photos,photo_upload,manage_pages,publish_stream', 'redirect_uri' => '');
         $loginUrl = $facebook->getLoginUrl($perms);        
         echo "<script>top.location.href='" . $loginUrl . "'</script>";        
    }

    $pageIds=$facebook->api('/me/accounts');
    $pageAccessToken=$pageIds["data"][1]["access_token"]; 

    $facebook->setAccessToken($pageAccessToken);



    $facebook->setFileUploadSupport(true);

    //Create an album
    $album_details = array(
            'message'=> 'My New Album',
            'name'=> 'My New Album'
    );
    $create_album = $facebook->api('/me/albums', 'post', $album_details);

    $album_uid = $create_album['id'];

    $photo_details = array(
        'message'=> 'Testing facebook API'
    );
    $file='images/Tanveer1.png'; 
    $photo_details['image'] = '@' . realpath($file);
    $upload_photo = $facebook->api('/'.$album_uid.'/photos', 'post', $photo_details);

    $make_cover_image = array(
        'cover'=> $upload_photo['id'],
        'offset_y'=> '60',
    );

    $json_object = $facebook->api("/Fan_Page_ID/?access_token=".$pageAccessToken,'post',$make_cover_image);

    print_r($json_object);

0 个答案:

没有答案