now i'm making application for facebook with javascript.but I don't know method to change my screen application to .jpg file.
So,I would like to know how to change my application and post it
Thank you for your help.
You cannot get the screenshot done client side, however you can grab the HTML code of the page being viewed and AJAX it up to your server, have your server component transform that HTML into an image.
Use this to get the HTML content of the page at the moment they want the screen capture document.getElementsByTagName('html')[0].innerHTML;
AJAX the HTML to your server
Have your server transform that HTML into an image (depending upon server-side technology you're using, there are solutions to this) (eg http://www.converthtmltoimage.com/)
two choice, store the image on your server to be the permanent place sending back the new URL for the image, or send the content back to the client.
Have the client HTTP Post the image content to Facebook for the post, or reference the URL
It's a big project, but I commend you for tackling something like this.
Related
Using the Open Graph protocol, an image can be signaled to applications such as Facebook to associate with a site link. For example:
<meta property="og:image" content="https://mysite.any/images/thumbnail.jpg">
However, this has a disadvantage: the image is a fixed one, i.e., it is always that same image whatever is the page. Obviously, using PHP, I can also select different existing images depending on the page being called, but doing this for any page on a site with hundreds of constantly updating pages is a mission impossible.
Ideally, I would like to be able to generate that image automatically when the server receives the HTTP call from the agent and generates the page content.
But how? Is there a simple way to do this, taking into account that the page is actually rendered by the browser and so the server actually has no idea how it will be represented? Probably I cannot do that by PHP but I need some JavaScript to do that. Is that correct?
This question exists in different flavors, but not for AJAX pages.
I use AJAX to pull a single video into my page and I want a custom FB share button for it. Everything I've read so far says that FB pulls the required title and image from meta-tags in the page's < head> section (og:image and og:title).
I've tried to change the meta properties when the AJAX call returns, before rendering the share button. This hasn't worked. It uses the values that were present upon initial page load. I have yet to encounter a single answer to this question.
Are there data attributes I can add to the 'fb-like' div to specify a custom title and image (similar to data-href)?
Danke!
You need an individual URL for each individual piece of content that you want to share. Open Graph objects (and simple shared links “become” such, automatically) are identified by their URL (og:url).
Now if your whole page is built on AJAX, you still need to create such individual URLs somehow – the Facebook scraper tool does not “speak” JavaScript, and relies solely on the OG meta information that the server delivers for any URL it requests.
Since the hash part of an URL is only of relevance client-side (and does not even get send to the server), “typical” AJAX URLs that rely on those to tell the client which piece of content to load in the background are no good here.
So if you want to share two pieces of content (videos) as http://www.example.com/?v=vid1 and http://www.example.com/?v=vid2, then you have to make sure that your server delivers the meta data for each video under its respective URL.
I'm trying to save a canvas image to the web page server, so a php script can post it to a web api. I've been looking around and all I see is saving it in the users web browser, any help for a newbie?
You can extract the contents of the canvas as a data url using the toDataURL method, and then upload this to your server using an AJAX POST.
The accepted answer to this question should give you some help.
I'm using a custom written auto uploader to import images from users to Amazon S3. I'm building up a parallel image library in my database, so I know what images I can access on S3 to not waste any http-requests.
However, my uploader sometimes throws errors (e.g. source image missing) and although I'm validating, I'm sometimes ending up with entries in my media table and no matching image on S3.
To correct these, I'm thinking of creating a cfthread/cfschedule which clears my image database from faulty entries. What I'm not sure is how to capture 404 responses. Right now I'm having this on a page:
<img src="#variables.imageSrc#" alt="#some alt#" title="#some title#" class="ui-li-thumb ui-corner-all" />
which tries to load the image and returns a 404 if not successful.
Question
How would I capture this 404? I don't want to put anything in the markup, so I assume this should go to onrequestend or another Coldfusion event being monitored in my application.cfc. If so, is there an easy way to identify image request, because I would not want to run a big routine on every applicationr request.
Thanks for insights!
EDIT:
I don't think running isDefined on every image before displaying it is feasable, because it will be a double request to S3 and there is a lot of images. I want to take the 404 and then clean up my database, so next time the image will not be accessed anymore.
If you don't want to use cfhttp and test each image like Matt suggested, why not trigger an ajax call from the browser using the onError handler of the img tag. Something like this but instead of showing a custom graphic, trigger your ajax to set your flag, or maybe even delete the image since it's happening invisible to the user. jQuery/JavaScript to replace broken images
More info on Image onerror Event
I'm curious to see how you would use isdefined on an image. From your code posted isdefined("variables.imageSrc") wouldn't help you much.
If you're running a scheduled task to do this, why not use cfhttp to perform a GET request on the image asset? You can then check the status code in the response to validate the file existence on the server, and then update the database accordingly.
this may be a stupid question.. but i decided to give it a try here...
i am developing a web application using AJAX to do the interactions between client and server(python/django).
now in the client page, there is a canvas which contains a dynamically generated image; i want to get this image and send this image to server, however, i can't use Canvas.toDataURL() due to the violation of canvas security rule (client and server must be in same domain in this case).
so I am just wondering whether it's possible to get the canvas element and send its HTML back to server, then let server process it and extract its image data?
appreciate any advice!
The only problem if the <canvas> date is tained by using images from different origins (CORS problem).
Just
Use toDataURL() to get the image data
Post this data to the server using normal AJAX
Strip off data URL prefix
base64 decode the data
Now you have image data in binary format
Do whatever you wish with the image
base64 + dataURL decode example: https://github.com/miohtama/Krusovice/blob/master/bin/create_bg_thumbnails.py#L62