What is the role of the key in a Google Photos Album url? - google-photos

Go to your Google Photos Albums page and hover over an album thumbnail. You'll see that an album's url looks like this:
https://photos.google.com/share/AF1QipN2T_IX-a4TjilksiuioY12GFNF59N-zaZQpz5vrD-QStk5C3FaLDJ1c5s1p_SJUJY5kA?key=MF9WbC0zRmpVZFQxTk9hT1lWdGVjUjV4UzRFbE
Does anybody know the role of the key?

This answer doesn't say exactly what the key's role is, but it's
a start.
Without the key, the url will open the album only for its owner.
With the key, the url will open the album for anyone, non-owners.
The non-owner will only have the right to look, not to edit.

Related

Wagtail: How to verify if a user can access a page in the template

I am creating a personal website using Django with Wagtail, in which users belonging to different groups can access certain pages. For example, the family group can see my holiday photos, while the co-workers group can see some internal documents.
Setting up permissions access permission is very straightforward through the admin. However, I would like to show a lock next to the link to forbidden pages. This will make it very clear to the user which links can be followed and which ones can't.
Is there any way to verify whether the current user has access to a given page?
After fiddling around with Wagtail's code, I've found that the permissions are handled through a model called PageViewRestriction (the code is very succinct and clear), which in turns inherits BaseViewRestriction that defines a method accept_request. Since the page to which is referring is store in the model, the only missing piece is the user requesting access.
With this, I've managed to put together a very simple template tag, which checks whether the current user can see the given page. The filter looks like this:
#register.simple_tag(takes_context=True)
def can_view(context, page):
pvrs = PageViewRestriction.objects.filter(page=page)
request = context['request']
if pvrs:
for pvr in pvrs:
if pvr.accept_request(request):
return True
return False
return True
Which in turn I use in my template like this:
{% can_view menuitem as permission %}
{% if not permission %}
<i class="fas fa-lock"></i>
{% endif %}
Note that in principle a page can have multiple different permissions specified. For example, members of different groups can view it. I assumed that if the current user belongs to one of those groups, or if the page does not specify view permissions, then the user can access that page.

A way to create the wall post when creating an album in a group with Facebook Graph API 2.10?

I used to do a POST /group-id/albums to create albums in a group. Then I would POST /album-id/comments to comment on the album. Then I would GET /group-id/feed?fields=comments, and find the id of my comment, and from that have the wall post id. You know, the post that says So and So added 3 photos to the album ...
Using the wall post id, I can delete the album, even though the Graph API does not allow deleting albums directly.
Starting today, the ability to post comments was removed through the API, except for page apps: https://developers.facebook.com/blog/post/2017/07/18/graph-api-v2.10/
Is there any way now, without commenting, to get the album story to the wall?
Here is a partial answer.
This parameter is not documented on the Group album, but it is on the User album. Set 'make_shared_album=true' in the post body. This will make a wall post for the creation of the album, and it looks like it shows up on your feed.
However, I cannot find a way to get that post_id. The post does not show up in the group's feed, oddly, though if you make a permalink to it, the permalink is part of the group. Sadly, the post_id is also not based on the album'd id, so there's no way to guess it.

How to setup a Django CMS 3 menu sitetree?

I want to have multiple site trees and, dependent of the role, display the corresponding menu.
For instance; this is my menu:
Site
Home
Products
Contact
User
Start
Admin
Now i can display my menu for a User like this:
{% show_menu_below_id "User" 0 1 0 1 %}
That will look like this: Start | Admin
The problem is that i want to have it start on "User/Start" and not on "User".
The url: /user/ should actualy by /user/start/
"User" should act like a tree node and i just need it to have an id to display the right tree, but that is about is, i do need it to start at... "Start".
I find it hard to find all ins en outs of Django CMS3 and i am sure/hope this is possible, but can not figure out how? I am not even sure where to look.
I found: add CMS_REDIRECTS = True to the settings.
then you can hardcode a url in the extra fields in the CMS.
Would be nice if it was not hardcoded, but i can continue now.

Photos uploaded to page as user are invisible to others

I have successfully uploaded photos to a Facebook Page that I am not the administrator of using the iOS FacebookSDK. However those photos are invisible to everyone except the uploader.
The page has the "Everyone can post to Page's timeline" and "Everyone can add photos and videos to Page's timeline" settings on.
I am using the following code, where self.photo is a UIImage:
FBRequest *request = [FBRequest requestForUploadPhoto:self.photo];
request.graphPath = #"<pageid>/photos";
request.session = [FBSession activeSession];
FBRequestConnection *conn = [FBRequestConnection new];
[conn addRequest:request completionHandler:^(FBRequestConnection *connection, id result, NSError *error) { ... }];
[conn start];
The upload / post is successful. If you view the page in question, as the user who uploaded the photo, you can see the photo on the page in the "Recent Posts by Others" box.
However, if you view that page as another user - no activity appears on the page and the "Recent Posts by Others" box is empty.
If that other user then uses the app to upload a photo in the same way, the same thing happens to them: they can see the photo they've uploaded but the first user cannot.
All photos uploaded by either user show to that user as "Shared with: Public" and "via" the application used. So it doesn't appear that they are hidden because of privacy or something like that.
I have seen many others post that they have been unable to upload photos to a page as a user (not the administrator of the page), e.g.:
Posting Photo to facebook fan page via iOS app by regular non-admin users
http://facebook.stackoverflow.com/questions/10795769/upload-photo-to-fanpage-from-application-user
http://facebook.stackoverflow.com/questions/7140097/facebook-create-app-for-page-to-upload-photos-to-pages-photo-album
http://facebook.stackoverflow.com/questions/12897746/user-image-upload-to-page-gallery
I have been able to upload the photo, but it only shows to the uploader! Is this some functionality that has changed? Am I running into a bug? It's very strange, I would love it if someone could shed some light!
Unfortunately it appears that while the Facebook API allows you to get further, it does still not work to upload photos to the timeline of a page.
This bug appears to be related and has been open for a while:
https://developers.facebook.com/bugs/246002638848837/
Success! It works, I have posted as a user to a Facebook page.
Where self.photo is an NSData:
NSDictionary *parameters = #{#"test.jpg": self.photo, #"message": self.message};
FBRequest *request = [FBRequest requestWithGraphPath:#"<pageid>/photos" parameters:parameters HTTPMethod:#"POST"];
Then the rest as per my question above.

Getting a list of people who liked a URL with Facebook like button

I'm trying to find the list user ids who clicked on the liked a url address via Facebook Like button.
What I have found so far is that, I can use FQL to get the like information for a facebook object like this:
SELECT user_id FROM like WHERE object_id = 123
With this query I can find the user_id list who like and object. Therefore i need to find the object_id of the url using this query:
SELECT id FROM object_url WHERE url = 'http://localhost/facebook_page.html'
However when I put the returned id to the first query, no result is returned. I have also looked at the url_like table, however I cannot query url column as it's not indexed.
I have found from somewhere else that I have to add fb:admins tag, and force the administrator to like the link for an "open graph page node" to be created in the Graph. I tried that but it did not seemed to work. I don't know how I can check if the "page node" is created or not because I was not able to find any references at all.
user_like table does not work for me, as I cannot use the url column on the where clause.
http://developers.facebook.com/bugs/250668685029065
It seems like it's not possible for now.