Share Facebook on iOS & Android [solved]

0 favourites
  • First of all can I say a big thank you to juannn91 for this excellent tutorial showing how to make posts onto Twitter and Facebook using the Browser object. The guidance in the tutorial required some modification to be made to the Browser object's js and, frankly, I stopped following at that point. I have managed to post to Twitter on iOS and Android and to Facebook on Android using an standard Browser object, but iOS requires the URL to be encoded somehow.

    hollowthreat pointed out in a comment that URLencode(str) could be used to encode the string instead. My problem is I don't know which part of the URL needs to be encoded. I've just spent a few hours trying to get this to work, by encoding all of the URL or just the last part after 'uri=', removing spaces and replacing etc and I've registered my app on Facebook and it works in Android... The best I have achieved using the URLencoder is a new Facebook window opening with the following error message:

    The dialog has passed a bad parameter

    API Error Code: 100

    API Error Description: Invalid parameter

    Error Message: redirect_uri URL is not properly formatted

    But at least it was in a new facebook window! So, I'm close but I can't think of what to do to get this last step to work. Any advice would be very welcome!


  • Urlencode the part with space, if you can't get it to work, post your url here, i'll try it, it also took me hours to figure out

  • hollowthreat - thank you for the offer of help! However, it seems that a night's sleep and a fresh look at the problem has helped me to solve this on my own. In case anyone else is looking for a solution to this problem, I used the following tool to get this to work (no need to do the conversion inside C2):

    This simple URL Encoder / decoder quickly does the job of converting a URL.

    It was just a case of substituting each URL in the browser go-to string with its converted URL. Simple!!

  • Hi.

    yes is simpler this way


  • Thanks Colludium, it works.

    But how to make it works with the Facebook app?

  • From what I've read it's not possible without finding a way to access the Cordova social APIs. I asked that question a couple of weeks ago in the help forum but no one seems to know how / if it can be done. I agree it would be ace to find a way, but at least this is a do-able alternative.

  • Hi!

    Trying out your method, Colludium, but I'm running into to trouble knowing what to encode and what not to. This is my url working on Android (decoded):

    " Check out my MyGame score of $"&points &"! &link= you beat my score?"

    I'm running my game through the CocoonJS app on iOS (thus not compiled in their cloud yet), if that makes any difference.

    Would really appreciate any help I could get!

  • Guddno, I recommend you encode the both links - from url to & and from uri to & (not including those). I think that'll work - at least that's what I did. I'm away from my computer and will check more when I can later.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Colludium

    Thanks for your reply! There are four URLs, which two should I encode?

    " Check out my MyGame score of $"&points &"! &link= you beat my score?"

    I really appreciate your help. I'm running into, what seems like, a thick wall here.

  • Guddno, A couple of observations that I hope will help. I think you have to encode every section between the &s where there are spaces (where you insert your own text for titles etc)! I thihnk these spaces are most of the problem and the secure link won't work while they are there. So I think your link should become something like: &link=


    There's a return after description= which may or may not copy-paste and cause you trouble and you still need to encode the urls (in red) that are not encoded from your first post (I've done the facebook link - green - as an example).

    Edit - I also noticed that you're missing an & between the facebook id and the display=popup (in blue)....

  • Thanks for helping out! After encoding the text it now works!

  • what you encode exactly ? only linkswith http or all

  • matrixreal, I suggest you encode each section of the link where there are spaces. Once you have a link with zero spaces then you should be good to go.

  • hi

    can you just tell me if its encoded properly :



    and i dont think that work with ejecta

  • Whatever you want to link to should first work if you were to just copy-paste it into your browser window. If it won't pass that test then there's something wrong. I can't get your link to work, because:

    your app id is "MYID" - you need a proper Facebook app id number here.

    caption= Check out my MyGame score of $"& HighScore &


    • there's a hard return and two &'s next to each other when this is decoded.

    and decoding the last part:

    redirect_uri= you beat my score?"

    Is your game registered on Facebook as MyGame? If not, that might cause a problem...

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)