I am trying to display a comments feed on my Facebook application, I am loading in an array of Facebook user ids and an associated comment, to display the users profile picture, I am using the following snippet:
<?php echo '<img src="http://graph.facebook.com/'.$c->_user.'/picture'" />; ?>
This works fine, and gets the image, however, if I refresh my page, I get some if not all of the thumbnails will not be loaded, refresh again and they'll always be there, it's pretty consistent that when I refresh they'll appear, next time they won't and so on.
Should I be dealing with this differently ? I know that in the browser the graph API redirects to the actual image, so maybe this is what's causing my browser to sometimes not display them, say if, it took too long to load the image ?
The issue is probably what genesis φ says says, just a temporary issue on Facebook's end. But to add on to his suggestions, you might try serving the image from https:. Alternatively, you can get the full, redirect-less picture URL from the user FQL table.
It's probably just their temporary issue. If you want to be sure, download them for the first time and you could "host" them more reliabily
Related
I have developed a daily csv file with php and mysql technology. Facebook uses this csv to show all our products on our facebook store.
The problem is that facebook displays a wrong image for some products. I have checked my csv and the image is right.
After that, I accessed to facebook catalog administration over a wrong image, then I saw that the product is showing the right image on the administration page.
Example:
Wrong image: https://www.facebook.com/products/image/?item_id=2344243688984642&display=multi&version=1&image_id=2169702346485626&image_width=186&image_height=186&display_option=background_padding&logging_boundary=item_preview
The right image that appears on 'edit product': https://external.xx.fbcdn.net/safe_image.php?d=AQCLCxZ9xrRUhd9m&url=https%3A%2F%2Fshop.atosa.es%2Fimg%2Fp%2F1%2F0%2F1%2F1%2F1011.jpg&_nc_hash=AQDWNd_Ct7njTn3V
It seems the wrong image is hosted by facebook and the right image by our server
I think that FB has a cache or something similar that do not update the image.
Any idea to update that wrong images?
I believe once before when you've been creating your catalog you still served a wrong image to FB. When FB fetches you feed now it sees the same URL and doesn't update the image because of that.
The solution would be to add any arbitrary parameter at the end of you image link like.
https://youserver/image.jpg?id=1
It should still return your image, but be a new link so that FB could recognize smth has change. It helped in many cases I had with wrong images in catalogs.
The ultimate solution would be to change the product's ID in the feed which will lead to FB creating an absolutely new product in the catalog. Mind, that it will discard product stats and you'll have to send that new ID in pixel or you mobile app.
Try the link solution first. You can also duplicate the product just adding a test one to the feed and check if a new fake test product looks correctly.
Let me know if it helps.
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.
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.
I have a Facebook app written in php that will display random quotes on your profile.
The box does not appear to update, it looks like it did when it was originally added.
I want to update the profile boxes on each page load (refresh), and not by a user action like clicking a link.
Any idea what is the problem and how to solve it?
This is how I did it for The Office Quotes application:
Put the random quote inside an image (many options to do this in PHP, I used the GD and Image Functions at http://us2.php.net/manual/en/ref.image.php to create a JPG containing the quote).
Accessing this dynamic image in a browser gives you a different random quote each time you refresh.
On the Facebook profile box or tab, simply link this image.
However, Facebook caches the image the first time it's loaded, so it never updates!
To force Facebook to update, you must update Facebook's image cache for the image's URL using the API function fbml.refreshImgSrc which is now accessed via the URL http://api.facebook.com/methods/fbml.refreshImgSrc and requires the access_token parameter like all other API requests. There was an announcement some time ago that this function was being deprecated, but the decision was reversed!
Setup the cache refresh code to run regularly. You can do this on a scheduled task (i.e. a cron job) or on each pageview in the application, or any other way you can think of that will cause the method to be run with the relative frequency the image will be requested by a user.
I also linked the image in the profile to a page in the app that would continually reload a new random image. Users generally would click to this page (which would refresh the image cache on each load) and they get the illusion that the image updates constantly.
Another illusion that I like even better is to add a 'Refresh' link in the profile box/tab that links to a script that refreshes the image cache and immediately returns to the user's profile, so that it actually appears to just be refreshing the profile box/tab.
Enjoy!
Profile content is cached by Facebook and does not connect to your server on every page load. This has always worked like this. No javascript runs on load/automatically, so you can't have a new quote displayed on page load.
What you can do is put a bunch of quotes in the profile content and us the fb:random tag to display a random quote on page load from the random option list. Periodically you can run a script to update the set of quotes in the user profile. If quotes are not unique to each user, you should use fb:ref handles so you just have to update the handle content, not each user's profile. Just put the ref handle in the user's profile.
I'm confused. Profiles boxes are all but gone. You shouldn't be developing anything for a profile box right now - it's just gonna disappear any day now anyway.
And even when profile boxes were still a suggested integration point, you couldn't update them in the way you are wanting to.
Using an iFrame, someone on my website can access their Facebook account, display a list of their photo albums, and then display photos from selected albums.
At the moment, when the user clicks a photo, I display a dialog box that shows the photo's path.
All of the above works perfectly.
My next step is to pass the photo's path info back to my web page, but I'm not sure how to do that because the object, to which I want to pass the data, is outside of the iFrame and therefore unknown to Facebook. I tried going top-down by referencing it through the DOM that contains the iFrame on my website...
parent.client.document.getElementById("FBPhoto").setValue(photoReference);
...but that didn't work.
Passing the argument to a PHP script, on my site, won't work because I don't want to fresh the page on my site (since that would cause the user to lose data).
From what you've provided it looks like your JS might be wrong.
Doing something like this might get you the value you need:
var photoReference = window.frames["iframe-name"].document.getElementById("FBPhoto");
Then you need to assign it to something:
MyObject.setValue(photoReference);
Note: window.frames["iframe-name"].document.getElementById("FBPhoto") will return the DOM element called #FBPhoto and will therefore be a big chunk of HTML. Your setValue() method might not be expecting that.
I suggest you try running your script in Firefox with Firebug installed, which will allow you to dump the value of photoReference to the console to see what you're getting back.
Doy... I realized that since the Facebook connection was running in a dedicated iFrame, it wouldn't be a problem to re-direct that frame because there was no reason to leave it open anyhow.
For anyone interested, here's what I did...
The PHP (inside of index.php) displays the album photos.
The PHP also surrounds each img frame with href tags.
The link points to a PHP file (on my website) and includes an argument with the location of the large version of the photo (since my app is displaying thumbnails). Something like: "< a href="pathToMySite/get-photo.php?photopath=facebook's path ">
When the user clicks on the desired photo, its respective link calls get-photo.php (on my site) and passes the path for the photo.
get-photo.php then inserts a reference to my website's main JS file into the document head, and inserts a script into the body of the HTML document.
The script calls a JS fetch-photo function, and passes the path argument that it received from the embedded iFrame that was running the Facebook app.
The JS function closes the iFrame (since I'm done with Facebook at that point) and grabs the photo from Facebook.