Search code examples
javascriptandroidfacebookcordovafacebook-canvas

Export html canvas5 photo to facebook using phonegap app on android


I am developing a phone gap app that uses html5 canvas to load an image then edit it and export.

I need to export to;

  1. Facebook
  2. Save in android device photo library

For uploading to facebook should I use graphAPI for php or graphAPI for javascript? Is there a specific encoding system I have to use before uploading to FB? (base64?) I do not want to use my own intermediate server to handle this.

I did research and couldn't find useful sources.


Solution

  • You can use this plugin to share in facebook

    https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin

    <button onclick="window.plugins.socialsharing.share(null, 'Android filename', 'data:image/png;base64,R0lGODlhDAAMALMBAP8AAP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAUKAAEALAAAAAAMAAwAQAQZMMhJK7iY4p3nlZ8XgmNlnibXdVqolmhcRQA7', null)">base64 image only</button>
    

    Convert the image into base64 encoding and share it in facebook with the plugin. (You can share in other platforms too)

    And to save the image see if this plugin helps you

    https://github.com/devgeeks/Canvas2ImagePlugin