Share Facebook on iOS & Android [solved]

Get help using Construct 2

Post » Mon Apr 07, 2014 3:20 am

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!

Thanks.
Last edited by Colludium on Mon Apr 07, 2014 2:24 pm, edited 1 time in total.
A big fan of JavaScript.
B
74
S
20
G
69
Posts: 2,206
Reputation: 43,834

Post » Mon Apr 07, 2014 11:01 am

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
Doo Doo Diving App Store | Google Play

Donut Pirate App Store | Google Play
B
17
S
2
G
1
Posts: 195
Reputation: 1,578

Post » Mon Apr 07, 2014 2:24 pm

@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!!
A big fan of JavaScript.
B
74
S
20
G
69
Posts: 2,206
Reputation: 43,834

Post » Tue Apr 15, 2014 11:34 pm

Hi.
yes is simpler this way
thank.
B
9
S
4
Posts: 49
Reputation: 1,239

Post » Wed Apr 16, 2014 12:10 pm

Thanks Colludium, it works.

But how to make it works with the Facebook app?
Banned User
B
16
S
3
G
3
Posts: 74
Reputation: 3,110

Post » Wed Apr 16, 2014 3:14 pm

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.
A big fan of JavaScript.
B
74
S
20
G
69
Posts: 2,206
Reputation: 43,834

Post » Thu Apr 24, 2014 1:06 pm

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):

"https://www.facebook.com/dialog/feed?app_id=MYID&display=popup&caption= Check out my MyGame score of $"&points &"! &link=http://mygame.com/&redirect_uri=https://facebook.com&name=MyGame&picture=http://www.MyGamePicture.png&description=Can 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!
B
5
S
1
Posts: 7
Reputation: 399

Post » Thu Apr 24, 2014 6:56 pm

@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.
A big fan of JavaScript.
B
74
S
20
G
69
Posts: 2,206
Reputation: 43,834

Post » Fri Apr 25, 2014 7:14 am

@Colludium

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

"https://www.facebook.com/dialog/feed?app_id=MYID&display=popup&caption= Check out my MyGame score of $"&points &"! &link=http://mygame.com/&redirect_uri=https://facebook.com&name=MyGame&picture=http://www.MyGamePicture.png&description=Can you beat my score?"

I really appreciate your help. I'm running into, what seems like, a thick wall here.
B
5
S
1
Posts: 7
Reputation: 399

Post » Fri Apr 25, 2014 11:39 am

@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:

https://www.facebook.com/dialog/feed?app_id=MYID&display=popup&caption=%20Check%20out%20my%20MyGame%20score%20of%20%24%22%26points%20&"! &link=http://mygame.com/&redirect_uri=http%3A%2F%2Fwww.facebook.com%2F&name=MyGame&picture=http://www.MyGamePicture.png&description=
Can%20you%20beat%20my%20score%3F

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)....
A big fan of JavaScript.
B
74
S
20
G
69
Posts: 2,206
Reputation: 43,834

Next

Return to How do I....?

Who is online

Users browsing this forum: Baidu [Spider], brunopalermo and 12 guests