I wrote the site in JavaScript and HTML5. It generates an image inside the canvas, and can save them to a computer. I want to add a button - to share in VKontakte
I found js for sharing content http://vk.com/js/api/share.js , and I also have this code on my site for saving images
function download() { //upload var dt = canvas.toDataURL('image/jpeg'); this.href = dt; }; downloadLnk.addEventListener('click', download, false); but I could not understand how to tie it together. I ask for advice on the implementation of loading canvas in VK. can i do without php? what about google itp
there are such thoughts, but so far I have no particular idea what to do next
<canvas id="myCanvas" width="578" height="200"></canvas> <script> var canvas = document.getElementById('myCanvas'); var context = canvas.getContext('2d'); // begin shape context.beginPath(); context.moveTo(170, 80); context.bezierCurveTo(130, 100, 130, 150, 230, 150); context.bezierCurveTo(250, 180, 320, 180, 340, 150); context.bezierCurveTo(420, 150, 420, 120, 390, 100); context.bezierCurveTo(430, 40, 370, 30, 340, 50); context.bezierCurveTo(320, 5, 250, 20, 250, 50); context.bezierCurveTo(200, 5, 150, 20, 170, 80); // complete custom shape context.closePath(); context.lineWidth = 5; context.fillStyle = '#8ED6FF'; context.fill(); context.strokeStyle = 'blue'; context.stroke(); //Convert canvas image to URL format (base64) var dataURL = canvas.toDataURL(); // Send it to server $.ajax({ type: "POST", url: "script.php", data: { imgBase64: dataURL } }).done(function(o) { console.log('saved'); }); </script> I read it https://vk.com/dev/photos.saveWallPhoto