Google Photos mediaItem.get not behaving as documented - google-photos

Per https://developers.google.com/photos/library/guides/access-media-items I am expecting that if I take mediaItem.baseUrl for an image, tack on =d to the end, and authorize the request, then i'll get back the media item's original bytes. This works as documented, good.
Per the same page, I am expecting that if I take mediaItem.baseUrl for an image, tack on =w375-h1135, and authorize the request, then I'll get back the media item's bytes after it has been resized using the specified width and height. Instead I get a 404.
Does specifying the resizing width/height only work for some cases? Makes it pretty useless to me if so... Anyone got the resizing to work? thanks

Turns out I was sending =w375.0-h1135.0 - as soon as I removed the .0 it worked.

Related

Facebook graph API - get custom profile picture size

I'm trying to get the logged in user's profile picture for a canvas app, but I would like to have it in a specific size.
Is this possible and, if so, how?
Currently I'm using the following:
graph.facebook.com/{user's FB ID}/picture?type=square
This gives me a 50px by 50px image. There are also options to use type=normal and type=large to give large image size, but these are not square images, and also not the exact size I am looking for.
To be specific, is there a way to get a member's profile picture in size 80px by 80px directly from Facebook, without downloading a larger image and downsizing/cropping on my end?
You can use width/height as parameter:
graph.facebook.com/{user's FB ID}/picture?width=100&height=100
Just keep in mind that you may not get exact sizes, but very close ones.
Getting a bigger facebook profile picture via facebook php sdk, this worked for me:
$response = $fb->get('/me?fields=picture.width(400).height(400)', getenv('FACEBOOK_ACCESS_TOKEN'));
in 2019!
https://graph.facebook.com/[[[[insertusersfbid]]]]/picture?type=large
Is what i fall back to...
https://graph.facebook.com/[[[[insertusersfbid]]]]/picture?width=2000&height=2000
Is when i want to muck with the image.
If the user does not have an uploaded profilepicture; now fb returns the gender based default pic...
I hope this helps someone else :)

Unpredictable display of Facebook og:image

We added Facebook Open Graph tags to our site NowGamer.com a few months back and everything worked perfectly initially. But in the last few weeks we've noticed that on about 2/3 of images the og:image would not display when an item was shared or liked. Sometimes going to the linter would scrape the page and the image would then be available.
But in other instances the image thumnbnail doesn't appear in the linter - although the link to the full image displays it at full size OK.
https://developers.facebook.com/tools/debug/og/object?q=http%3A%2F%2Fwww.nowgamer.com%2Fnews%2F1298151%2Fassassins_creed_3_join_or_die_freedom_collectors_editions_details.html
The images all fit within the 3:1 parameters although they are relatively large (they have to be as they are screenshots for video games). Here is an example of exactly the same type and size of image that does display in the Linter and on shares/Likes
https://developers.facebook.com/tools/debug/og/object?q=http%3A%2F%2Fwww.nowgamer.com%2Fps3%2Fps3-reviews%2F1293635%2Fresident_evil_operation_raccoon_city_review.html
I can't see why one works and the other doesn't. Any suggestions?
The thumbnail's width AND height must be at least 50 pixels, and
cannot exceed 130x110 pixels.
http://developers.facebook.com/docs/share/
Strange: I would have gone with a cache problem which I've also experienced before. For pure testing purposes if you want to attempt to refresh a different version of the URL try adding ?v=1 or some other parameter which makes the URL unique. This forces Facebook to go and get the URL again so you can make sure the images are working as expected.I think YouTube have also had this problem over the last few months http://groups.google.com/a/googleproductforums.com/forum/#!category-topic/youtube/sharing-and-connecting-on-youtube/YnTqofAhcN8

creating/displaying an image based on user input -- Django

In Django, I want to create an image using an R function (so via Rpy2) based on user input (POST) and then display that image back to the user.
My approach: Save the image to a file and display it in the template (the same template as the form).
1) Is this the right approach?
I then found that sometimes when I submit the form a few times with different parameters, I get the same image back when I shouldn't, so some kind of caching is going (in the browser?). I was also concerned with accidentally passing the image created by one user to another simultaneous user.
So when the form is submitted, I add a random number to the name of the image, getting a new image name (and new image) every time.
2) Is this a reasonable approach?
I have an intuition that I'm doing things the stupid way, but I'm not sure what I should be doing.
To get the browser cache, you can simply add a random query parameter of the url of the image, like this
<img src="assest/images/img1.png?randomstring/>
As for if it's a reasonable approach, it depends whether these image need to be re-generate every time the user visit the page. It this is the case, you'd better serve these images directly by a view, like this. Otherwise you will need to delete these images that will never be used again.
If somehow you do need to reuse these images, just remember there must be a mechanism that prevents your hard drive been used up.

Caching data (image, rss) with django

That's my first question in here, I've been looking through old questions, but nothing matched with my problem. Here it is.
I'm creating some site with one main functionality. We want this site to display content of other sites, but in a specific way. User chooses let's say two pages from five and want to see their content. He clicks button 'Display' and goes to next page where he finds let's say view from web cam, and here comes problem.
I want to cache image that is hidden behind the url from which image was downloaded, so after refresh image won't be downloaded again, but browser will get it from cache.
I've been looking through documentation of Django, but nothing seemed to be useful.
I know that I should:
1) create table which stores cache
2) add to settings.py some CACHE_BACKEND = ...
3) use #cache_page(300) before declaration of function which returns content which should be cached,
but... it doesn't seem to work.
I will be greateful if someone tells how to solve that problem, maybe with some sort of code showing the mechanism.
Cheers,
Chris.
I think that right way to do this will be to store image somewhere on your server and delete it later with cron or something similar.
Django cache framework wasn't created for the purpose you are trying to use it.

Is it possible to tell if a user has viewed a portion of the page?

As the title says on a website is it possible to tell if a user has viewed a portion of the page?
Will moving that portion to a separate iframe work? then if they scroll to the bottom, issue a get request for a small image file..forgot the name of the technique..
Update: It is called Web Bug..A Web bug is an object that is embedded in a web page or e-mail and is usually invisible to the user but allows checking that a user has viewed the page or e-mail. One common use is in e-mail tracking. Alternative names are Web beacon, tracking bug, tracking pixel, pixel tag, 1×1 gif, and clear gif.
If you are talking about to check if the user has actually viewed some part of the page you would need to install a web camera and track his eye-movement.
If you are talking about detecting how far the user has scrolled down the page, you can use Javascript to detect this in the OnScroll event. You can then fire some ajax to the server if you need to record this.
I'm not sure this would be ethical - but technically if you use javascript, you could detect the mouseover event of each paragraph tag in the document, and then AJAX that information back to the server. As the user scrolls down the page, they're likely to mouse over the paragraphs, and then you know at least approximately where they've read to.
Not reliably, no.
Simple example: I middle-click on a link, which opens it in a new background tab. I then decide against it, and close the tab without ever looking at it. Any JavaScript trick is going to report that I viewed everything above the fold.
More complicated example: A newbie user doesn't have the browser window maximised, and a portion of the browser window is off-screen. Any JavaScript trick is going to report as if the entire viewport is being viewed, so even restricting your query to only the cases where scrolling occurs will not help.
Unless you require a user action of some kind, all you will be able to tell is that they downloaded some portion, not that they actually looked at it.
Sure. Put that content inside a div, then in your html, with some javascript, capture the onmouseover event and do your work there. If they've put their mouse over something, it's a pretty safe bet that they've seen it, I'd say...
Hope this helps.