Hi MErickson,
I have managed to get it work based on your suggestion given.
Really thanks and appreciate for the guidance.
Below is my code that retrieve the list of ACL, hope it benefit others
as well:
'OAuth
Dim requestFactory As New GOAuthRequestFactory(CONST_PICASA_SERVICE,
CONST_PICASA_ALBUM_APP_NAME)
requestFactory.ConsumerKey = GoogleConsumerKey
requestFactory.ConsumerSecret = consumerSecret
'Picasa Service
Dim service As New PicasaService(CONST_PICASA_ALBUM_APP_NAME)
service.RequestFactory = requestFactory
' Requires the query happen over a secure connection
service.RequestFactory.UseSSL = True
'Picasa Album Query
Dim query As New AlbumQuery()
query.Uri = New Uri(PicasaQuery.CreatePicasaUri(userID))
query.OAuthRequestorId = userID
query.Thumbsize = "144c"
'Picasa Feed
Dim feed As PicasaFeed = service.Query(query)
'initialize album object list
Dim albums As New List(Of Object)
While feed IsNot Nothing AndAlso feed.Entries.Count > 0
For Each entry As PicasaEntry In feed.Entries
'create an album
Dim alb As Album = New Album
alb.AtomEntry = entry
'retrieve the acl entry link
Dim aclAtomLink As AtomLink =
entry.Links.FindService(AclNameTable.LINK_REL_ACCESS_CONTROL_LIST,
Nothing)
If Not aclAtomLink.HRef Is Nothing AndAlso Not aclAtomLink Is
Nothing Then
If aclAtomLink.HRef.ToString.Trim.ToLower.Contains("data/
entry/api") Then
'retrieve the album ID
Dim albID As String =
alb.PicasaEntry.GetPhotoExtensionValue(GPhotoNameTable.Id).ToString.Trim
'replace the entry link to feed link
Dim aclLink As String =
aclAtomLink.HRef.ToString.Trim.ToLower.Replace("data/entry/api",
"data/
feed/api")
Dim aclList As List(Of String) =
GetAlbumACL(userID, albID, aclLink)
If aclList.Count <> 0 AndAlso Not aclList
Is Nothing Then
'change the access level from
protected to limited
alb.Access =
Util.StringValueOfEnum(AccessLevel.AccessLevelLimited)
End If
End If
End If
albums.Add(alb)
Next
If feed.NextChunk IsNot Nothing Then
Dim nextChunkUri As Uri = New Uri(feed.NextChunk)
query.Uri = nextChunkUri
query.OAuthRequestorId = userID
feed = service.Query(query)
Else
feed = Nothing
End If
End While
Private Function GetAlbumACL(userID As String, albumID As String,
aclLink As String) As System.Collections.Generic.List(Of String)
Try
'declaration of variable
Dim aclList As New List(Of String)
'OAuth
Dim requestFactory As New
GOAuthRequestFactory(CONST_PICASA_SERVICE,
CONST_PICASA_ALBUM_APP_NAME)
requestFactory.ConsumerKey = GoogleConsumerKey
requestFactory.ConsumerSecret = consumerSecret
Dim aclService As New Service(CONST_PICASA_ALBUM_APP_NAME)
aclService.RequestFactory = requestFactory
' Requires the query happen over a secure connection
aclService.RequestFactory.UseSSL = True
'Picasa ACL Query
Dim aclQry As AclQuery = New
AclQuery(aclLink.ToString.Trim)
aclQry.OAuthRequestorId = userID
'Picasa ACL Feed
Dim aclFeed As AtomFeed = aclService.Query(aclQry)
For Each aclEntry As AtomEntry In aclFeed.Entries
Dim elementList As New ExtensionList(aclEntry)
Google.GData.Client.Utilities.FindExtensions(aclEntry.ExtensionElements,
GAlbumNameTable.Person, GPhotoNameTable.NSGPhotos, elementList)
For Each element As IExtensionElementFactory In
elementList
If Not CType(elementList(0),
Google.GData.Extensions.XmlExtension).Node Is Nothing Then
Dim node As XmlNode = CType(elementList(0),
Google.GData.Extensions.XmlExtension).Node
For Each attr As XmlAttribute In
node.Attributes
If
attr.Name.ToString.Trim.Equals(GAlbumNameTable.Email,
StringComparison.CurrentCultureIgnoreCase) Then
If Not attr.Value Is Nothing Then
aclList.Add(attr.Value.ToString.Trim)
End If
End If
Next
End If
Next
Next
Return aclList
Catch
Throw
End Try
End Function
On Feb 10, 2:05 am, Michael Erickson <[email protected]> wrote:
> It looks like you're loading a list of albums, then looking on each entry
> for the ACL link and loading that?
>
> I will recommend a slight modification to your strategy:
>
> 1. Load the list of albums.
>
> 2. For each album, load the album feed.
>
> 3. From the album feed, grab the ACL feed link: <link
> rel='http://schemas.google.com/acl/2007#accessControlList'
> type='application/atom+xml'
> href='http://picasaweb.google.com/data/feed/api/user/103...795/albumid/562....
>
>
>
> 4. Load that href.
>
> The reason for the extra call to load the album feed is that the ACL link
> on the album entry is for the ACL entry href instead of the ACL feed href,
> and the ACL entry href doesn't have any useful information in it.
>
> Let me know if you have trouble with that.
>
> -Mike
> On Feb 9, 2012 9:07 AM, "Howdy" <[email protected]> wrote:
>
>
>
> > Hi Guys,
>
> > How can I retrieve the access control list of an Album?
> > I am using OAuth with the Consumer Key and Consumer Secret.
> > I can't seems to get the feed of "http://schemas.google.com/acl/2007".
>
> > Thanks and appreciate for the help.
>
> > Below if my code:
>
> > Dim requestFactory As New GOAuthRequestFactory(CONST_PICASA_SERVICE,
> > CONST_PICASA_ALBUM_APP_NAME)
> > requestFactory.ConsumerKey = GoogleConsumerKey
> > requestFactory.ConsumerSecret = consumerSecret
>
> > Dim service As New PicasaService(CONST_PICASA_ALBUM_APP_NAME)
> > service.RequestFactory = requestFactory
> > service.RequestFactory.UseSSL = True
>
> > Dim query As New AlbumQuery()
> > query.Uri = New Uri(PicasaQuery.CreatePicasaUri(userID))
> > query.OAuthRequestorId = userID
> > query.Thumbsize = "144c"
>
> > Dim feed As PicasaFeed = service.Query(query)
> > Dim albums As New List(Of Object)
>
> > While feed IsNot Nothing AndAlso feed.Entries.Count > 0
> > For Each entry As PicasaEntry In feed.Entries
>
> > Dim link As AtomLink =
> > entry.Links.FindService(AclNameTable.LINK_REL_ACCESS_CONTROL_LIST,
> > Nothing)
> > If Not link Is Nothing Then
> > Dim aclQry As AclQuery = New
> > AclQuery(link.HRef.ToString.Trim)
> > aclQry.OAuthRequestorId = userID
>
> > aclQry.Etag = entry.Etag
>
> > Dim aclFeed As AclFeed =
> > CType(service.Query(aclQry), AclFeed)
>
> > For Each acl As AclEntry In aclFeed.Entries
> > Console.WriteLine(acl.Scope.Type.ToString)
>
> > Console.WriteLine(acl.Scope.Value.ToString)
> > Console.WriteLine(acl.Role.Value.ToString)
> > Next
> > End If
>
> > Dim alb As Album = New Album
> > alb.AtomEntry = entry
> > albums.Add(alb)
> > Next
>
> > If feed.NextChunk IsNot Nothing Then
> > Dim nextChunkUri As Uri = New Uri(feed.NextChunk)
> > query.Uri = nextChunkUri
> > query.OAuthRequestorId = userID
> > feed = service.Query(query)
> > Else
> > feed = Nothing
> > End If
>
> > End While
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Google Picasa Web Albums API" group.
> > To post to this group, send email to
> > [email protected].
> > To unsubscribe from this group, send email to
> > [email protected].
> > For more options, visit this group at
> >http://groups.google.com/group/google-picasa-data-api?hl=en.- Hide quoted
> >text -
>
> - Show quoted text -
--
You received this message because you are subscribed to the Google Groups
"Google Picasa Web Albums API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-picasa-data-api?hl=en.