I have used the html2canvas-php-proxy 0.1.11 to save facebook photos into Divs. / p>
The problem is that sometimes the images inside the divs do not show the facebook photos, they are blank. I believe that the Html2canvas does the "printscreen" before the facebook images are uploaded.
<script type="text/javascript" src="canvas/html2canvas.js"></script>
<script type="text/javascript" src="canvas/jquery.min.js"></script>
<script type="text/javascript" src="canvas/jquery.plugin.html2canvas.js"></script>
<div id="target" style="position:absolute; width:800px; height:420px;">
// AQUI É EXECUTADO CODIGO PHP QUE RETIRA IMAGENS DO FACEBOOK
</div>
<script type="text/javascript">
var sProxy = 'html2canvasproxy.php';
$('#target').html2canvas({
"proxy": sProxy,
useCORS: true,
onrendered: function (canvas) {
//Set hidden field's value to image data (base-64 string)
$('#img_val').val(canvas.toDataURL("image/png"));
//Submit the form manually
var img = canvas;
document.body.appendChild(img);
document.getElementById("myForm").submit();
}
});
</script>
<form method="POST" action="save.php" id="myForm">
<input type="hidden" name="img_val" id="img_val" value="" />
</form>
This code automatically redirects to save.php to save the image
<?php
session_start();
//Get the base-64 string from data
$filteredData=substr($_POST['img_val'], strpos($_POST['img_val'], ",")+1);
//Decode the string
$unencodedData=base64_decode($filteredData);
//Save the image
file_put_contents('image.jpg', $unencodedData);
?>
Sometimes I use https://html2canvas.appspot.com/query
on the proxy site, and it even works better .. The problem is that sometimes appspot.com has dead hours or is overloaded and does not work.
Is it better to use https://html2canvas.appspot.com/query
or html2canvasproxy.php?
My server does not support python. If I host the python script on another server and use it on the proxy, will it work better?
PS: I'm using html2canvas.js 0.4.1, because if I switch to 0.5.0-alpha1 then there are still more blank images / no facebook images.