I'm trying to access Places photos using the photoreference.
This works:
https://maps.googleapis.com/maps/api/place/photo?maxwidth=800&photoreference=CnRsAAAAGrxlcgShBlZZJgAFxr19eT3fQKxeDTpN4HtyCIsUpOHjUPqB_tm_J_Rf9sbwyWU1j4_SSRWyFiIT0TYGDSn6mAwAQ6ep-9Rok0kAEf6LewL8CRYbaEVoEsfrZXs_BIwUcqNs5p1TQv-EMt-PO8RloBIQHF40AvYJVknRixv4uFYVVRoUGKN_fqy7qynsrclqkBbAdaIpi58&key=MY_KEY
But this one doesn't:
https://maps.googleapis.com/maps/api/place/photo?maxwidth=800&photoreference=CnRnAAAADBlPZditZugHCXmMtb0_qQqwyh3rJ0ByTxnI_MRXXEB7Cj_I1QgTKi7XMUAXbD3YMEH8yPdfIH-u-uoM0ZnMsLY6l0eF0Ip9JTkqkw5tgE_eD6RUhgOztHJ312JRWIFkJq2faixmtTM4DILp4WsWaRIQQy53oVWAfP68T60TsYQSNxoUZDjyv0kLie1ZGNzDrF2YgqqktWo&key=MY_KEY
Both photoreferences are valid.
I can access about 50% of the pictures, the other 50% gives me a 403 error. I have a paid license key, and am not over the limit (anyway it's not that the first 50% works and then it gives 403, but quite random, some work, some don't).
Any ideas?
The photo seems to have been removed (or made private) by its owner.
Your 2nd Places Photo request (link) returns a redirect:
HTTP/1.1 302 Found
Location: https://lh5.googleusercontent.com/-gMRov-DClsg/UkYcLUa5mtI/AAAAAAAAJiI/48Zbe7GvS9I/s1600-w800/photo.jpg
The response for that photo.jpg URL is simply HTTP 404 Not Found.
Try to get the image with php function: file_get_contents
Related
I am trying to use the Soundcloud API. I make a request backend which works fine. I get the track id and with that i call api.soundcloud.com/tracks/242264498/stream?client_id=[REMOVED]. That link works fine in both Chrome and Firefox. However, when using it with jQuery/HTML it seems to fail in Firefox.
Request:
$(".jukebox").prop("src", 'https://api.soundcloud.com/tracks/'+track_id+'/stream?client_id=2487d5f911c4c44f0882c063ec104332').trigger('play');
Response (ONLY Firefox):
GET https://ec-media.sndcdn.com/C21H6loBzYez.128.mp3 [HTTP/1.1 403 Forbidden 23ms]
Running this in Firefox console plays the track for less than 1 second. I can hear it "stutter". Then it gives the 403.
$(".jukebox").prop("src", 'https://api.soundcloud.com/tracks/'+242264498+'/stream?client_id=2487d5f911c4c44f0882c063ec104332').trigger('play');
The HTML looks like this:
<audio class="audio_file jukebox" controls preload="auto" data-volume="0.25"></audio>
Just tested your code. And it worked fine even in firefox too.
https://ec-media.sndcdn.com/C21H6loBzYez.128.mp3
This url will simply not work, it needs access token id and other GET parameters. If SoundCloud is redirecting you to this url (with no GET parameters such as access token id and any others) then it may be something with SoundCloud as its not a 'normal' behavior.
I suggest you to re-test your code as it worked fine for me.
Say I have this route handler in my Express.js app:
app.get('/files/:name', function (req, res) {
res.sendfile('path/to/files/' + req.params.name + '.html');
});
This path is used via Ajax on my site. I wonder if I should guard against situations where a file with the requested name does not exist on the server, in which case the server returns a 404 response. I can work with this, i.e. detect the 404 in the browser and act accordingly (e.g. display a message to the visitor). However, I'm not sure if this is a good approach. Is it OK to use the 404 response here, or am I supposed to try to avoid 404 responses if possible. (E.g. I could if a file with the requested name exists on the server and only use .sendFile() if it does.)
I'm worried that performing a manual check would only slow things down as .sendFile() already has this check built-in (i.e. it's possible to avoid this check and instead detect 404 responses in the browser which is what I'm doing right now and it works fine).
I would stick with returning a 404 instead, as that's the 404's purpose.I'm not sure there really is any other common/practical alternative.
Good luck.
I'm using a simple example from the README file (from AFNetworking 2.0 page) to download an image. All works fine for the images served directly from my web-sever.
But for those located on the S3 the web-server returns 302 Redirect the following error:
Error Domain=NSURLErrorDomain Code=-999 "cancelled"
When I try to download the image (using the same code) directly from the S3 (omitting the redirection) I receive the same error.
I've checked the availability of the actual image with wget. The image is publicly available (https://youguide.s3.amazonaws.com/icons/user_96x96.png).
Anyone experience the similar problem?
I was having the same problem with S3 and seem to have resolved it. AFNetworking was returning a value in the authentication challenge handling logic that was canceling the request.
By telling the AFURLSessionManager how to handle authentication challenges I've fixed the problem.
[manager setSessionDidReceiveAuthenticationChallengeBlock:^NSURLSessionAuthChallengeDisposition (NSURLSession *session, NSURLAuthenticationChallenge *challenge, NSURLCredential * __autoreleasing *credential) {
return NSURLSessionAuthChallengePerformDefaultHandling;
}];
I am creating a simulation game (web service), and need to fake those error pages. As far as I know, and can see, there isn't a way to fake a 404, or 500 etc. Is this right? Are we able to do this programmatically?
I know I could just make a 404 page and redirect to it... But I'm trying to make it a little more realistic.
Returning a 404 or 500 status code to the browser (see your programming language's/framework's documentation for how) will send a real one instead of a fake one.
Copy whatever page your server sends for those particular errors (or just read the existing files if you've specified them explicitly) and write that out, then send the right status code along with it. For example, in PHP:
header("HTTP/1.1 500 Internal Server Error");
Here's how I'd do it using PHP:
<?php
header('HTTP/ 404'); //So that the browser thinks it's a legitimate 404 error.
#readfile($_SERVER['DOCUMENT_ROOT'] . '/404.html') or die('404 Not Found'); //Replace "/404.html" with your 404 page.
?>
I have an RP for which I've built a login page using the Json feed from ACS. The IP images are linked to the .LoginUrl attribute of the feed and when I click on one of the images it correctly jumps to that IP's page.
Entering my credentials, however, I'm redirected to a page on the appfabriclabs.com site with the following error:
HTTP Error Code: 400
Message: ACS50000: There was an error issuing a token.
ACS50011: The RP ReplyTo address is missing. Either the RP ReplyToAddresses
are not configured or an invalid wreply 'https://www.skillscore.it/' was received
in the sign-in request.
the RP is configured in the App Labs site with a returnUrl of:
https://www.skillscore.it/Home/FederationResult
and in looking at the wreply parameter in the feed, I see:
https%3a%2f%2fskillscore.accesscontrol.appfabriclabs.com%3a443%2fv2%2fwsfederation
According to some SO articles like [this one] the return url of the app should be a prefix of the wreply parameter - which is clearly not the case here.
so... what have I done wrong now?
e
p.s. one interesting bit of info: in the Application Integration page of ACS there is a link to the ACS-hosted login page. the link used there seems to differ from the one I'm given in the feed; in particular, the ACS-hosted page uses a wctx of:
pr%3dwsfederation%26rm%3dhttps%253a%252f%252fwww.skillscore.it%252f
whereas the feed gives me:
pr%3dwsfederation%26rm%3dhttps%253a%252f%252fwww.skillscore.it%252f%26ry%3dhttps%253a%252f%252fwww.skillscore.it%252f
so I don't know what that's worth but maybe it's a clue to what's wrong.
* update *
decoded, that last string is:
pr=wsfederation
&rm=https%3a%2f%2fwww.skillscore.it%2f
&ry=https%3a%2f%2fwww.skillscore.it%2f
which clearly shows the Json feed is providing an ry that is not present in the ACS-hosted page... meaning anything to anyone?
ok. my bad. apparently, when I was fetching the Json feed, the URL I used did not have the reply_to set correctly.