Facebook

Konig Studios

  • Posts: 76
See: http://community.stencyl.com/index.php/topic,26710.0.html

========

Could someone with some coding knowledge look into this?

https://github.com/hyperfiction/HypFacebook

I think this is what is needed for Facebook integration into Stencyl. I have tried to mess around with it but haven't gotten very far.

Thanks

« Last Edit: March 24, 2014, 11:11:56 am by Jon »

losh

  • Posts: 28
I didn't write this...

Assuming you have created your facebook app and filled in all the correct data in the facebook developer website, you can continue to downloading the actual API and putting it somewhere you'll remember (preferably close to your project or haxe folders), extract everything from the zip file.
Now, create a file called 'include.nmml' at the root of the API folder with this code:
<?xml version="1.0" encoding="utf-8"?>
<project>

<java path="src" />
<java path="libs/android-support-v4.jar" />

</project>

And create a haxe file in that folder which will be responsible for all JNI communications (it's more comfortable to have one file responsible of all the operations).
And now you need to create the corresponding java file which will have all the functions called from JNI.
You also need to create a new MainActivity.java file for your app, which will include the full code from this tutorial (only the activity code is required):http://developers.facebook.com/docs/tutorials/androidsdk/3.0/scrump...

After you've created those files, you'll need to create the R.java file to put in src/com/facebook/android, which will be created from the facebook resources. You can create that file using aapt which can be found under your Android SDK folder, in platform-tools. Run the following command (where ANDROID_HOME is the location of your Android SDK folder, and DEV_HOME is the location of your project):
ANDROID_HOME/platform-tools/aapt
package
-v
-f
-m
-S DEV_HOME/res
-J DEV_HOME/src
-M DEV_HOME/AndroidManifest.xml
-I ANDROID_HOME/platforms/android-7/android.jar

More data about aapt can be found here:http://geosoft.no/development/android.html... and here:http://elinux.org/Android_aapt
You might also need to create the BuildConfig.java file if you don't have it, I have attached it. (you just need to change its extension because I couldn't upload it with the java extension)

Lastly, for the facebook folder, you need to go to the 'res\values' folder, and open the strings.xml file and add two lines:
<string name="app_name">NAME</string>
<string name="app_id">ID</string>

You can find your appID using the android keytool (make sure you have openssl installed) with the following command on windows:
keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%\.android\debug.keystore | openssl sha1 -binary | openssl base64

and the following command on OS X:
[quotekeytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64][/quote]

Now, you also need to create a new AndroidManifest.xml file that will override the existing haxe one, so it will include the facebook activity. The correct AndroidManifest.xml file is attached (built using the template AndroidManifest.xml).

Now that you're done with all of that, go to your application's nmml file to include all the files that we've added.
Add the following lines (change the path to the correct path to your android facebook API files and all the other files you've added and change 'xxxxxxx', 'yyyyy' to be your correct package name):
<include path="../facebook-android" if="android" />
<template path="../facebook-android/res" rename="res" if="android" />
<template path="AndroidManifest.xml" if="android" />
<template path="../facebook-android/src/MainActivity.java" rename="src/com/xxxxxx/yyyyyyy/MainActivity.java" if="android" />


I can help you though.

Konig Studios

  • Posts: 76
I am looking for something for iOS. I should have specified in the main post. I will definitely try this though if I move into android. Thanks a lot.

mbuist

  • Posts: 252
I didn't write this...

Assuming you have created your facebook app and filled in all the correct data in the facebook developer website, you can continue to downloading the actual API and putting it somewhere you'll remember (preferably close to your project or haxe folders), extract everything from the zip file.
Now, create a file called 'include.nmml' at the root of the API folder with this code:
<?xml version="1.0" encoding="utf-8"?>
<project>

<java path="src" />
<java path="libs/android-support-v4.jar" />

</project>

And create a haxe file in that folder which will be responsible for all JNI communications (it's more comfortable to have one file responsible of all the operations).
And now you need to create the corresponding java file which will have all the functions called from JNI.
You also need to create a new MainActivity.java file for your app, which will include the full code from this tutorial (only the activity code is required):http://developers.facebook.com/docs/tutorials/androidsdk/3.0/scrump...

After you've created those files, you'll need to create the R.java file to put in src/com/facebook/android, which will be created from the facebook resources. You can create that file using aapt which can be found under your Android SDK folder, in platform-tools. Run the following command (where ANDROID_HOME is the location of your Android SDK folder, and DEV_HOME is the location of your project):
ANDROID_HOME/platform-tools/aapt
package
-v
-f
-m
-S DEV_HOME/res
-J DEV_HOME/src
-M DEV_HOME/AndroidManifest.xml
-I ANDROID_HOME/platforms/android-7/android.jar

More data about aapt can be found here:http://geosoft.no/development/android.html... and here:http://elinux.org/Android_aapt
You might also need to create the BuildConfig.java file if you don't have it, I have attached it. (you just need to change its extension because I couldn't upload it with the java extension)

Lastly, for the facebook folder, you need to go to the 'res\values' folder, and open the strings.xml file and add two lines:
<string name="app_name">NAME</string>
<string name="app_id">ID</string>

You can find your appID using the android keytool (make sure you have openssl installed) with the following command on windows:
keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%\.android\debug.keystore | openssl sha1 -binary | openssl base64

and the following command on OS X:
[quotekeytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | openssl sha1 -binary | openssl base64]

Now, you also need to create a new AndroidManifest.xml file that will override the existing haxe one, so it will include the facebook activity. The correct AndroidManifest.xml file is attached (built using the template AndroidManifest.xml).

Now that you're done with all of that, go to your application's nmml file to include all the files that we've added.
Add the following lines (change the path to the correct path to your android facebook API files and all the other files you've added and change 'xxxxxxx', 'yyyyy' to be your correct package name):
<include path="../facebook-android" if="android" />
<template path="../facebook-android/res" rename="res" if="android" />
<template path="AndroidManifest.xml" if="android" />
<template path="../facebook-android/src/MainActivity.java" rename="src/com/xxxxxx/yyyyyyy/MainActivity.java" if="android" />


I can help you though.
[/quote]

Can you make this in an extension

Like post score on user wall. Or share the game url on users wall
Visit my arcade site - http://www.tincubegames.com/
Read all about my games at - http://www.tincubemedia.nl
Please follow Tincube Media on Facebook - http://www.facebook.com/tincubemedia

As a final touch.. GOD created the Dutch

mbuist

  • Posts: 252
Visit my arcade site - http://www.tincubegames.com/
Read all about my games at - http://www.tincubemedia.nl
Please follow Tincube Media on Facebook - http://www.facebook.com/tincubemedia

As a final touch.. GOD created the Dutch