authorProfileImageUrl returns only a tiny thumbnail - youtube-api

I'm trying to use YouTube Data API to get a list of comments for a video.
The problem is that the field authorProfileImageUrl in the response contains a URL to a tiny thumbnail (28x28 pixels) of the profile image instead of the bigger one (48x48) that can be seen in YouTube's comment section. How can I retrieve the bigger one? Am I missing some magic parameter in the request that selects the size of the profile images in comments?
Here's my request URL:
https://www.googleapis.com/youtube/v3/commentThreads?videoId=VIDEO_ID&part=snippet&fields=pageInfo,items(snippet(topLevelComment(id,snippet(authorDisplayName,authorChannelUrl,authorProfileImageUrl,authorChannelId,textDisplay,likeCount,publishedAt)),totalReplyCount))&maxResults=3&key=API_KEY
Edit:
Here's an example profile pic URL i get:
https://yt3.ggpht.com/-b-fXZSZ0hPw/AAAAAAAAAAI/AAAAAAAAAAA/mq4JpF46xq4/s28-c-k-no-mo-rj-c0xffffff/photo.jpg
^^
I noticed that the marked part seems to select the size, because when I change the 28 to 48, the size of the profile pic changes too.
I could change it "manually" with some fancy regexp, and it will work, but it will also rely on implementation details that are undocumented and that may change in future and render the application broken :P So it really would be better if there was a documented API way to do that.

Seems like nobody knows how to solve this, ho here's my temporary solution.
It works, but it depends on an implementation detail that can change in the future and then the solution will break apart and will have to be corrected :q
I accept my own answer for now, but when someone posts a better one, I'll accept it instead.
The solution:
I made a simple function that searches for the image size in the URL string and replaces it with a bigger size.
function small2big(url)
{
return url.replace(/(\/.*s)28(.*\/photo.jpg)$/,"$1"+"48"+"$2");
}
Oh, and here's my middle finger for you, Google: ,,|,,

It seems that actually removing everything right at the 's28' will display the entire image without specifying a size.
For example, instead of this:
https://yt3.ggpht.com/-b-fXZSZ0hPw/AAAAAAAAAAI/AAAAAAAAAAA/mq4JpF46xq4/s28-c-k-no-mo-rj-c0xffffff/photo.jpg
You can use this: https://yt3.ggpht.com/-b-fXZSZ0hPw/AAAAAAAAAAI/AAAAAAAAAAA/mq4JpF46xq4/
And it will return the full size image.
In my case, using php I simply:
function bigAvatar($url) {
$url = substr($url, 0, strpos($url, 's28'));
return $url;
}
Again, if google decides to change this in the future, this would break. But for now, it works.

Related

How can I get Giphy's gifs with using Swift Giphy Client?

I found some framework which namely Giphy Client, to use the Giphy's gifs easily. But there is no tutorial on how to use it. Sorry for this rookie question. Can someone explain me to how can I search the gifs and get them with using this client?
Here is the gif search function :
func test(){
let gif1 = Giphy(apiKey: "dc6zaTOxFJmzC")
gif1.search("lol", limit: nil, offset: nil, rating: nil) { (gifs, pagination, err) in
}
}
I really don't know what's in the gifs value and I'm struggling because of that. There is a lot of subclass like url, id or rankings, but I can't figured it out.
All the information is available on the GitHub page you linked in your question. To find more about the gifs variable, you can use Xcode's Utilities menu (the right side bar) to see documentation when you click on a variable or function.
Alternatively, you can jump to the definition of a variable by holding command and clicking it. The information about the Gif object is available here on GitHub as well.
It looks like the gifs variable is an optional array of Gif objects (its type is [Gif]?).
The Gif object has some useful properties like id, rating, and giphyURL (a URL pointing to the actual gif image).
Since you most likely want to get the images themselves, you can make network requests to get the actual image data. This has already been covered extensively on Stack Overflow. Here is an answer to get you started with getting image data from a url: https://stackoverflow.com/a/27712427/6658553

How to copy class and function name in Blackfire report

When I am copy-pasting method name from Blackfire profile, I am getting a reversed string like this:
sgnitsiLredivorPdaol::yrotisopeRresopmoC\yrotisopeR\resopmoC
What is intended way to copy a proper method name (not reversed)?
Why does Blackfire has such behaviour? Is this some kind of stupid joke or copy-paste protection?
This is indeed a UX issue we currently have in Blackfire, let me explain it to you:
We want to display the end of the namespace/classname value in this part of the interface
We want to have a text-overflow ellipsis on the left part of the value.
Unfortunately, using text-overflow: ellipsis on the left of the text is not supported by modern browsers at the moment.
There are two ways to do that: Either know the width of the text, work with a fixed width column and truncate programmatically or use a hack, revert the letters, change the text direction from left-to-right to right-to-left locally and use traditional text-overflow.
As we deal with a resizable UI here, we chose the second option, and this is the one that provide the better experience at the moment. However, as you notice, this issue remains.
We're thinking about a fix for this issue. It might be with the Clipboard API.
In the meantime, here's the way you can copy/paste the value :
Just expand a node and copy from the inner box, see:
Hope it helps you until we find a better solution.

JQGrid: How to override saveparameters url for inlineNav addRow?

I need to explicity specify the url for adding a row via inlineNav.
But, I do not know HOW to do that, other than something called saveparameters has the url value I need to specify, documented here: http://www.trirand.com/jqgridwiki/doku.php?id=wiki:inline_editing&s[]=addrowparams
However, function that uses that is saveRow, and that is called by inlineNav save button using default saveparameters, which has wrong URL (the window location, because grid has not editurl specified).
QUESTION: How can I configure jqGrid saveparameters with the url my inlineNav save button needs?
I could put 8 or 10 URLs here showing many asking same question and no answer. Is this stupid question, or not supported or possible?
Any help much appreciated.

Advantages to randomizing an order status URL?

Is there an advantage in randomizing the URL for order statuses?
Right now, the URL is based on an incrementing order number, like blah.com/orderstatus/1, blah.com/orderstatus/2 and only the user is able to see his own order. If he tries to look at somebody else's order by changing the number in the url, he will receive an error.
Are there any disadvantages of doing this?
Doing this is good, in fact almost every website use index like that.
Using a random index will make it very complicated, and is absolutely not recommended.

Is there a best method to evaluate URL variables to determine the appropriate page?

I am using ColdFusion 9.0.1.
I have a new web site that uses Bikes.cfm and Makers.cfm as template pages. I need to be able to pass BikeID and MakerID to both of the these pages, along with other variables. I don't want to use the Actual page name in the URL, such as this:
MyDomain.com/Bikes.cfm?BikeID=1234&MakerID=1234
I want my URL to look more like this:
MyDomain.com/?BikeID=1234&MakerID=1234
I need to NOT specify the page name in the URL.
I want these two URLs to access different data:
MyDomain.com/?BikeID=1234&MakerID=1234 // goes to bike page
MyDomain.com/?MakerID=1234&BikeID=1234 // goes to maker page
So, if BikeID appears in the URL before MakerID, go to the Bikes.cfm page. If MakerID appears before BikeID, go the Makers.cfm page.
Is there an easy and existing method to arrange the URL keys in such a way to have them point to the appropriate page?
Should I just parse the the URL as a list and determine the first ID and go to the appropriate page? Is there a better way?
Any thoughts or hints or ideas would be appreciated.
UPDATE -- It certainly appears that using the order of parameters in a URL is a bad idea for the following reasons:
1) many programs append variables to the URL
2) some programs may reorder the variables
3) GoogleBot may not consider order relevant and will most likely not index the site correctly.
Thanks to everyone who provided advice in a positive manner that my approach was probably a bad idea and would not produce the results I wanted. Thanks to everyone who suggested alternate means to produce the results I wanted.
If anyone of you positive people would like to put your positive comment/advice as an answer, I'd be happy to accept it as the answer.
Despite my grave misgivings about the whole idea, here's how I would do it if I were forced to do so:
index.cfm:
<cfswitch expression="#ListFirst(cgi.query_string, '=')#">
<cfcase value="BikeID">
<cfinclude template="Bikes.cfm">
</cfcase>
<cfcase value="MakerID">
<cfinclude template="Makers.cfm">
</cfcase>
<cfdefaultcase>
<cfinclude template="Welcome.cfm">
</cfdefaultcase>
</cfswitch>

Resources