Facebook module
Monkey Forums/Monkey Programming/Facebook module
| ||
Released my facebook code with support for more dialogs in proper module format. Currently supports Wall Posting Friend Requests Application Requests Dependancy on Diddy still so this also needs to be in your modules folder. http://code.google.com/p/facebookmonkey/ |
| ||
That's cool! |
| ||
this is now going into my current project, facebook is such a big deal now having tools like these is essential. saw on sky news last night that 1 in 9 people ON THE PLANET are on facebook. holy crap. |
| ||
Too bad there is no like functions here. Where did you get the links? I want to add a like function to it if it's possible. |
| ||
Yeah +Like would be nice. would help spread awareness of the game to others via their social circles. |
| ||
Edit: Extra " in code removed I thought about adding it but it doesnt behave how you would expect, In order to do things without verification you have to gain an access token which is beyond this plugin. Clicking the like button would bring up a webpage with another like button (the official one) I find its best to stick the like button in the HTML of a flash or Html5 game rather than on the canvas regardless ive updated the source and added this code Function FBLike() LaunchBrowser("http://www.facebook.com/plugins/like.php?href="+varAppUrl,True) End http://developers.facebook.com/docs/reference/dialogs/ |
| ||
Thanks a lot!!! |
| ||
Great. Thanks |
| ||
Many Thanks!!! one thing concerning this: If AppURL.Contains("http://") = True url can contain also "https://" so I'd make like: If AppURL.Contains("http://") = True Or AppURL.Contains("https://") = True Then |
| ||
your right I will make this change in the source |
| ||
Also, I noticed, that URL must NOT contain spaces. Use "%20" instead! 'Not working!!! FBWallPost("Jet Worm", "Never sleep during the party!", True) 'Working FBWallPost("Jet%20Worm", "Never%20sleep%20during%20the%20party!", True) check the Name in FBSetUpApp as well! I know, it's obvious, however I spend an hour or so to sort this out =) (iOS tested, works perfectly!) |
| ||
Which browser did the above fail in as I thought that at first but it passed in everything I tested without converting to %20 |
| ||
I tested on iPod, so it's iOS v5.1 Safari browser. Works well with spaces on html5 Google Chrome. |
| ||
Ok made some changes, no error for spaces just converts them on the fly to "%20". Removed the requirement for URLs to be in lower case Added the HTTPS:// Suggesstion 'Copyright (c) <2012>, <Adam Fryman> 'All rights reserved. 'Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 'Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 'Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 'THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 'THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS 'BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 'GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 'LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Import diddy Global varAppID:String Global varAppName:String Global varAppURL:String Global varAppLogo:String Function FBWallPost(Caption:String,Message:String,Popup:Bool) If varAppID <> "" Then Local lvarDisplayType:String Local lvarMessage:String = Message.Replace(" ","%20") If Popup = True Then lvarDisplayType="popup" Else lvarDisplayType = "page" LaunchBrowser("https://www.facebook.com/dialog/feed?app_id="+varAppID+"&link="+varAppURL+"&picture="+varAppLogo+"&name="+ varAppName + "&caption="+Caption+"&description="+lvarMessage+"&redirect_uri="+ varAppURL+"&display="+lvarDisplayType,Popup) Else Error("FACEBOOK MODULE ERROR: Cannot send message, the fb application settings are incorrect") EndIf End Function Function FBSetUpApp:int(AppID:String,AppName:String,AppLogoURL:String,AppURL:String) 'Sanitise AppID If AppID.Length > 30 Then Error("FACEBOOK MODULE WARNING: AppID is incorrect") Return 0 Else varAppID = AppID EndIf 'Sanitise AppName If AppName.Length > 60 Then Error("FACEBOOK MODULE WARNING: App name is too long") Return 0 Else varAppName = AppName.Replace(" ","%20") EndIf 'Sanitise Logo if AppLogoURL.Contains(".gif") = True or AppLogoURL.ToLower.Contains(".png") = True or AppLogoURL.ToLower.Contains(".jpg") = True or AppLogoURL.ToLower.Contains(".jpeg") Then varAppLogo=AppLogoURL Else Error("FACEBOOK MODULE WARNING: The app logo must be a link to gif/jpg/png stored on the internet, all in lower case, it cannot be an image embedded in the app") Return 0 EndIf ' Sanitise App Url if AppURL.ToLower.Contains("http://") = True or AppURL.ToLower.Contains("https://")Then varAppURL = AppURL Else Error("FACEBOOK MODULE WARNING: The App url needs to be a web address, it also needs to be registered to your app on the facebook developers site") Return 0 EndIf End Function Function FBRequestPost(Message:String,Popup:Bool) Local lvarDisplayType:String Local lvarMessage:String = Message.Replace(" ","%20") If Popup = True Then lvarDisplayType="popup" Else lvarDisplayType = "page" LaunchBrowser("http://www.facebook.com/dialog/apprequests?app_id="+varAppID+"&message="+lvarMessage+"&redirect_uri="+varAppURL+"&display="+lvarDisplayType,Popup) End Function Function FBFriendRequest(FacebookID:String,Popup:Bool) Local lvarDisplayType:String If Popup = True Then lvarDisplayType="popup" Else lvarDisplayType = "page" LaunchBrowser("http://www.facebook.com/dialog/friends/?id="+FacebookID+"&app_id="+varAppID+"&redirect_uri="+varAppURL+"display="+lvarDisplayType,Popup) End Function FBLike() LaunchBrowser("http://www.facebook.com/plugins/like.php?href="+varAppUrl,True) End Updated Zip |
| ||
still doesn't work :( sorry. I tried even replace the whole URL. didn't help Just need to manually replace spaces with %20 |
| ||
Which bit doesn't work? URL, Message, Description? Edit: Scrap that its a mistake in my code, didnt change the variable name from message to lvarmessage, Ive updated the post above, the ZIP should be correct though as my local version is correct I just forgot to update the forum |