Need a way for Facebook to render an image in wall posts. Sometimes, all you need to do is copy and paste the link to the image, like here:
But, with the images I need to link to, which are on S3, I get this:
You can click here to verify that the second link is in fact a valid image address (you should see a creepy hand drawn smiley face).
I did this test just using the normal Facebook GUI on the site, but I will be using the answer to this question in my app, which integrates with Facebook via the Open Graph API. (In case anyone thought this question was not programming related).
Anyone know what I need to do to get the second image to render in the post?
The key is image size. Don't ask me what the magic number is, but larger images work and smaller ones don't. It could be that it has to be larger than the preview size that facebook uses.
In my test, I had static website configuration turned off.
My guess is only static links will generate a thumbnail for posts on facebook. The link you are trying to use not a static one.
This is what Facebook gets when trying to generate a thumbnail.
<Error>
<SCRIPT/>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>D577337ADC9FA36A</RequestId>
<HostId>
DN9BnBduVLgHbf2lONA+e/fXQIOuT7W3WOFUPdthdpP2MZQhSLlolTvyJ0t9eZXn
</HostId>
</Error>
Solution :
It turns out that to make it work, you cannot just map any arbitrary subdomain to any arbitrary bucket. The fully qualified subdomain name must be the same as the S3 bucket name.
Suppose the name of your site is static.mydomain.com. Then you need
to create a S3 bucket with that same name, named
static.mydomain.com.
Once you configure that bucket as a S3 static web site, it will have
a URL assigned to it that looks something like http://static.mydomain.com.s3-website-us-east-1.amazonaws.com.
Go to your domain host and map your subdomain to the URL from step 2. In enom.com, that meant mapping the host "static" to the address "static.mydomain.com.s3-website-us-east-1.amazonaws.com" as a CNAME
record.
Source, it will help you host a static site from your S3 account. Use images from that custom domain URL path. That will work.
Related
After uploading an image, I get back metadata that has a mediaDownloadLink that will download the file when accessed. Is there a way to get a link that will display the image in the browser without downloading it?
In general, any object you set to be publicly accessible (which presumably you wanted to do to use it to host images on a website), you can then access with https://storage.googleapis.com/<bucket>/<object>. You can see this link also if you go to the cloud console and make an object publicly viewable and look for the Public link you can click.
If you have problems with the link downloading instead of displaying by itself in a browser, you may need to make sure the content-type header is set correctly; for example if using ByteArrayContent to upload data using the Java API, you'll want to set a string like "image/jpeg" in its constructor for "type".
I spotted that one (just one, rest is ok) shared link on wall of group I am in isn't look properly. It's just grey rectangle, you can see it on included image. I wonder why it's displayed this way because I copied url and pasted it to facebook open graph object debugger. There are no warnings and preview generated by tool is ok (so image pass dimension requirements). I also tried to put that url on my profile and I can see image. Sorry that I don't paste urls here but I don't think I'm allowed to do this. I hope someone still want to answer my qestion. What is reason of this behaviour?
Grey rectangle on shared link
There can be several reasons for this situation.
I assume you use some service provider to generate image.
Facebook crawler visits your site and make POST request which uses no cache content, which also makes your site fresh render for facebook request but also may cause timeout error in some cases. If image thumbnail is generated with some service provider it can be the cause.
Thumbnail service providers often causes mistakes by themselves. Take under consideration that what you see on facebook wall is the very first render of the image in the thumbnail provider. Check twice parameters that you send to the service and maybe there is some problem with alpha channel (if it's PNG image).
That's for my guesses. Hope it will help you.
When I request a photo from Facebook, some urls are like this:
https://{hidden_for_privacy}79141548_n.jpg
And others are like this:
https://{hidden_for_privacy}23364315_n.jpg?oh=c566c56ca9fd7eb1ed5d8bfca4255e84&oe=544AF123&__gda__=1414682395_6d2cb778f5b2c857d1be1c781e81cdfa
The second one has a few extra GET parameters (oh, oe and __gda_ _ (space is there to prevent bold).
When these parameters exist, the image will be invalid after a few days because those values will be different (you can check this by doing a new API call to get the same photo).
What do these parameters mean and how are they linked to the maximum timeframe?
Thanks!
I know some history and its purpose.
Originally facebook image url look like this
https://{*snipped*}/XXXXXXXXXXX_b.jpg
but there are more than on size of image available so people have access to thumbnail image can simply replace suffix _b with _n
(So now it is https://{*snipped*}/XXXXXXXXXXX_n.jpg)
to access to larger version of the image (if available).
Some time later facebook implements central image system that can dynamically crop and resize image on the fly upon request.
The url provided by facebook at this point of time may look like this:
https://{*snipped*}.fbcdn.net/hprofile-xxx1/v/t1.0-1/p32x32/12345678_123412341234123_4123412341234123412_n.jpg
And when people see the url their curiosity arise.
Let's try remove some parameter from the url.
https://{*snipped*}.fbcdn.net/hprofile-xxx1/v/12345678_123412341234123_4123412341234123412_n.jpg
And what they get is the largest and most complete version of the image they can possibly get from facebook server.
This method was working for a long time.
When people see image in their email (mostly profile picture) they can get complete version of image without even log into facebook.
It was working everywhere include private profile picture.
The quick fix and cheapest solution for facebook is to sign request path with some signature algorithm.
I guess they use HMAC as the core algorithm and derive HMAC input from various source including request path.
This will ensure that the only party who can generate valid url is the one who have HMAC key. (presumably just facebook)
Now old issue is fixed you can not use it anymore but there are more than one issue that can be fixed by adding MAC.
It is invalidation of access to images.
Let say people once publish their photo (now other can have both valid request path plus signed signature from facebook) and later on they change their mind and make the photo private.
However, people with valid url and signature can still fetch the image from facebook server.
To solve this issue with super cheap resource considered that they already implements HMAC calculation.
(And to obscure the fact that facebook does not actually delete your image from their system when you delete it.)
They decided to mix value derived from timestamp into input of HMAC.
(See RFC-6238 for similar usage)
So signature refreshing from facebook is periodically required to gain access to photo.
This solved the latter issue with very cheap additional resource.
And here you have it.
Some of history and rationale behind facebook's parameters.
I'm certain that there is no official document about the time frame but it should not be difficult to do some experiment yourself considered that now you know that the value of time frame you want is fixed and predictable.
I think they are facebook image session keys and they produced by facebook on every image showing. So fb servers consider that the request for an image is allowed and known by facebook itself.
Sorry for my bad English and my shallow comment, but i think the solution of this problem may be that fetch a url for a new image session when old one expired. Or i don't know your whole system but maybe you can connect to that assign-keys-for-images mechanism of facebook directly and get all fresh links.
If I am right about those parameters' working mechanisms purposes, i think there is no second solution.
Sorry for my bad English again.
I found the answer (finally). The point is that the photos are not public. If you request a private photo through the API they add a query string so that the url is not valid anymore after some time. Therefore the photo is still somewhat "private". The feature is understandable and there is no workaround other than downloading the image to some other place.
My domain is hosted with a popular domain name company, whos name I won't mention.
Then my website is hosted by a hosting provider.
Yet, for some reason the domain name company, only allows the Meta Description and Meta Keyword tag in URL Frames.
That leaves me with the following problem, I can't put the following code in the URL Frame (or Iframe):
<meta property="og:image" content="url of thumbnail"/>
This is needed for Facebook to pick up the thumbnail when being posted.
Is there any way I can achieve this without switching domain hosting?
.Htaccess maybe?
Your problem is one of many issues with using frames.
Search engines and other services (like Facebook) can’t work with your domain, as it always points to a different resource (everyone would always be lead to the home page of your site when following the link).
You could use the "real" URL of your page (i.e., of the frame), which is probably the one provided by your hosting provider.
Right click on your page, the context menu should show something like "Load this frame only". That’s the URL of your page. For images, a right click on the image and something like "Copy image URL".
You should definitely switch to a hosting/domain provider that allows you to use the full power of your domain.
I have a page I cannot fetch the public profile image from. Why is that, and why does it happen?
The page in question is: (WARNING: NSFW-ish images of strippers, real sorry, only example I could find - no need to view the page anyway)
https://www.facebook.com/pages/Texas-Poolhouse/98758030102
I can access the page through the graph API. Notice that the results tell me the ID is 98758030102, as expected:
https://developers.facebook.com/tools/explorer/?method=GET&path=98758030102
And even get the image URL this way too:
https://developers.facebook.com/tools/explorer/?method=GET&path=98758030102%2Fpicture
However, using the ID, I cannot fetch the image the way I normally do. I just get a blue question mark:
http://graph.facebook.com/98758030102/picture
Are you sure you're using an access token from a user who can see the page? I can see the correct image when using my own access token - if you're not using an access token you're limited to the information which is publicly available and given the nature of the page it's probably limited to adults only because of its alcohol and/or stripper content.
I realize that this is an old question but I will add my answer for future searchers since this worked for me.
You say that using this as the image URL does not work. http://graph.facebook.com/98758030102/picture
Well I got curious and changed the http:// to https:// and entered my page ID in place of yours and it worked.
I am assuming by turning the connection secure it allows the graphi api to fetch the image.
This URL should work.
https://graph.facebook.com/YOUR_PAGE_ID_NUMBER/picture
Adding the access_token GET parameter to the url makes sure users who are allowed to view the page image will see it (18yo++ in this case). I have, however, not found a way to, through the API, determine when or why pages are not accessible by certain users.