Closed paala closed 10 years ago
Hi,
call()
function to request a dialog, like the FEED_DIALOG
: // Present a feed dialog
function feedDialog( ) : Void {
var h = new Hash<String>( );
h.set("name","Facebook extension for NME");
h.set("caption","Build great social apps and get more installs with Haxe/NME.");
h.set("description","The Facebook extension for NME makes it easier and faster to develop Facebook integrated apps build with Haxe");
h.set("link","http://www.nme.io");
h.set("picture","https://raw.github.com/fbsamples/ios-3.x-howtos/master/Images/iossdk_logo.png");
fb.call( FEED_DIALOG( h ) );
}
Note that for posting scores on Facebook you should use the [https://developers.facebook.com/docs/games/scores](Graph API for scores).
See ec574fc
I didn't get it correctly, So, I have a button:
private function onbuton2():Void { //fb.connectForRead(true,fbpermissionarrayread); //fb.connectForPublish(true, fbpermissionarray); //fb.connectForRead(true,fbpermissionarrayread); //fb.requestNew_read_permissions( ["user_about_me"] ); fb.requestNew_publish_permissions(["publish_actions"]);
}
When I click the button in logcat: 06-02 15:32:28.470: W/System.err(7906): at com.facebook.Session.requestNewPermissions(Session.java:968) 06-02 15:32:28.470: W/System.err(7906): at com.facebook.Session.requestNewPublishPermissions(Session.java:501)
06-02 15:32:28.470: W/System.err(7906): at fr.hyperfiction.HypFacebook.requestNew_publish_permissions(HypFacebook.java:290)
Same message with requestreadpermission.
06-02 15:38:34.450: W/System.err(8543): com.facebook.FacebookException: Attempted to use a Session that was not open.
if i use feed dialog , no matter if i call requestread permission before
Have you correctly open a Facebook session before requesting additionnal permission? You need to do things like this:
import flash.display.Sprite;
import fr.hyperfiction.HypFacebook;
class Main extends Sprite {
var fb : HypFacebook;
public function new () {
super ();
connectToFacebook( );
}
function connectToFacebook( ) : Void {
fb = new HypFacebook( "your_app_id" );
var session_is_valid = fb.connect( false ); // false to disallow login UI
if( session_is_valid ) {
_doFacebookStuff( );
} else {
fb.addEventListener( HypFacebookEvent.OPENED, _onFbOpened );
// open session with minimal read permission
fb.connectForRead( true, ["public_profile"] ); // true to allow login UI
}
}
function _onFbOpened( _ ) {
fb.removeEventListener( HypFacebookEvent.OPENED, _onFbOpened );
_doFacebookStuff( );
}
function _doFacebookStuff( ) {
fb.addEventListener( HypFacebookRequestEvent.GRAPH_REQUEST_RESULTS, _onGraphResults );
// you now have a valid facebook session, you can start making Graph request
// when your application needs it, request additional permission from the user.
fb.requestNew_publish_permissions( ["publish_actions"] );
}
function _onGraphResults( event : HypFacebookRequestEvent ) : Void {
// read the result here
trace( 'sResult:'+event.sResult );
}
}
This native extension is just a thin wrapper on top of the Android and iOS Facebook SDK. You may need to read the Facebook SDK docs about login on Android to implement the correct workflow.
Also as noted in the README, sometimes the cached session on your phone is broken when your application is in sandbox mode. You need then to clear all data from your app or try without having the FB app installed.
I replaced my Main.hx with yours : but the function _doFacebookStuff() is never executed. I placed a trace inside trace("facebook request permission") that doesn't appear in logcat.
I think the problem is that after connect for read the session is bSessionValid ::: false
I uninstalled and clear cache of the app every time I did a new build.
Full Logcat:
06-03 11:34:50.475: I/trace(17049): HypFacebook.hx:45: constructor ::: 1420285291578270 06-03 11:34:50.480: D/dalvikvm(17049): Trying to load lib /data/app-lib/com.paala.testhaxe-2/libhypfacebook.so 0x4274f328 06-03 11:34:50.480: D/dalvikvm(17049): Added shared lib /data/app-lib/com.paala.testhaxe-2/libhypfacebook.so 0x4274f328 06-03 11:34:50.480: D/dalvikvm(17049): No JNI_OnLoad found in /data/app-lib/com.paala.testhaxe-2/libhypfacebook.so 0x4274f328, skipping init 06-03 11:34:50.480: I/trace(17049): HypFacebook null: 1420285291578270 06-03 11:34:50.480: I/trace(17049): HypFacebook.hx:61: connect 06-03 11:34:50.495: I/trace(17049): HypFacebook.hx:73: bSessionValid ::: false 06-03 11:34:50.495: I/trace(17049): HypFacebook.hx:78: facebook connect for read 06-03 11:34:50.975: I/trace(17049): HypFacebook.hx:90: bSessionValid ::: false 06-03 11:34:50.980: I/trace(17049): Java_fr_hyperfiction_HypFacebook_onFBEvent 06-03 11:34:50.985: I/trace(17049): HypFacebook.hx:304: _onEvent ::: OPENING - - 06-03 11:34:50.985: I/trace(17049): HypFacebook.hx:337: pas connu 06-03 11:34:50.985: I/trace(17049): HypFacebook.hx:344: OPENING?? 06-03 11:34:52.645: D/FacebookSDK.WebDialog(17049): Webview loading URL: https://m.facebook.com/dialog/oauth?display=touch&client_id=1420285291578270&scope=public_profile&type=user_agent&redirect_uri=fbconnect%3A%2F%2Fsuccess 06-03 11:34:53.215: D/FacebookSDK.WebDialog(17049): Redirect URL: https://m.facebook.com/login.php?skip_api_login=1&api_key=1420285291578270&signed_next=1&next=https%3A%2F%2Fm.facebook.com%2Fv2.0%2Fdialog%2Foauth%3Fredirect_uri%3Dfbconnect%253A%252F%252Fsuccess%26display%3Dtouch%26scope%3Dpublic_profile%26type%3Duser_agent%26client_id%3D1420285291578270%26ret%3Dlogin&cancel_uri=fbconnect%3A%2F%2Fsuccess%3Ferror%3Daccess_denied%26error_code%3D200%26error_description%3DPermissions%2Berror%26error_reason%3Duser_denied&display=touch&_rdr 06-03 11:34:53.215: D/FacebookSDK.WebDialog(17049): Webview loading URL: https://m.facebook.com/login.php?skip_api_login=1&api_key=1420285291578270&signed_next=1&next=https%3A%2F%2Fm.facebook.com%2Fv2.0%2Fdialog%2Foauth%3Fredirect_uri%3Dfbconnect%253A%252F%252Fsuccess%26display%3Dtouch%26scope%3Dpublic_profile%26type%3Duser_agent%26client_id%3D1420285291578270%26ret%3Dlogin&cancel_uri=fbconnect%3A%2F%2Fsuccess%3Ferror%3Daccess_denied%26error_code%3D200%26error_description%3DPermissions%2Berror%26error_reason%3Duser_denied&display=touch&_rdr 06-03 11:34:53.655: D/FacebookSDK.WebDialog(17049): Webview loading URL: https://m.facebook.com/login.php?skip_api_login=1&api_key=1420285291578270&signed_next=1&next=https%3A%2F%2Fm.facebook.com%2Fv2.0%2Fdialog%2Foauth%3Fredirect_uri%3Dfbconnect%253A%252F%252Fsuccess%26display%3Dtouch%26scope%3Dpublic_profile%26type%3Duser_agent%26client_id%3D1420285291578270%26ret%3Dlogin&cancel_uri=fbconnect%3A%2F%2Fsuccess%3Ferror%3Daccess_denied%26error_code%3D200%26error_description%3DPermissions%2Berror%26error_reason%3Duser_denied&display=touch&_rdr 06-03 11:35:07.425: D/FacebookSDK.WebDialog(17049): Webview loading URL: https://m.facebook.com/login.php?auth_token=6bbc8ede2794da1779709974940cff81&skip_api_login=1&signed_next=1&next=https%3A%2F%2Fm.facebook.com%2Fv2.0%2Fdialog%2Foauth%3Fredirect_uri%3Dfbconnect%253A%252F%252Fsuccess%26display%3Dtouch%26scope%3Dpublic_profile%26type%3Duser_agent%26client_id%3D1420285291578270%26ret%3Dlogin&refsrc=https%3A%2F%2Fm.facebook.com%2Flogin.php&refid=9 06-03 11:35:08.680: D/FacebookSDK.WebDialog(17049): Redirect URL: https://m.facebook.com/v2.0/dialog/oauth?redirect_uri=fbconnect%3A%2F%2Fsuccess&display=touch&scope=public_profile&type=user_agent&client_id=1420285291578270&ret=login&ext=1401788109&hash=AeZjwQpAEtOFg_9L&refsrc=https%3A%2F%2Fm.facebook.com%2Flogin.php&refid=9&_rdr#_=_ 06-03 11:35:08.690: D/FacebookSDK.WebDialog(17049): Webview loading URL: https://m.facebook.com/v2.0/dialog/oauth?redirect_uri=fbconnect%3A%2F%2Fsuccess&display=touch&scope=public_profile&type=user_agent&client_id=1420285291578270&ret=login&ext=1401788109&hash=AeZjwQpAEtOFg_9L&refsrc=https%3A%2F%2Fm.facebook.com%2Flogin.php&refid=9&_rdr#_=_ 06-03 11:35:28.260: D/FacebookSDK.WebDialog(17049): Webview loading URL: https://m.facebook.com/v2.0/dialog/oauth/confirm
Another fact I noticed is that if I comment out the line """"
in project.xml nothing changes , so maybe the problem is that I am not using the correct mainactivity
EDIT: I think: https://github.com/hyperfiction/HypFacebook/blob/haxe3/templates/android/MainActivity.java should extend org.haxe.lime.gameactivity, but still doesn't work
The Facebook API respond to your call with this:
/success?error=access_denied&error_code=200&error_description=Permissions+error&error_reason=user_denied
If your app is in sandbox mode, you may need to 'activate' your test user.
Hi, I made the app public wait 1 hour and the same:
06-03 14:09:27.925: I/trace(27387): HypFacebook.hx:45: constructor ::: 1420285291578270 06-03 14:09:27.935: D/dalvikvm(27387): Trying to load lib /data/app-lib/com.paala.testhaxe-2/libhypfacebook.so 0x4274e448 06-03 14:09:27.935: D/dalvikvm(27387): Added shared lib /data/app-lib/com.paala.testhaxe-2/libhypfacebook.so 0x4274e448 06-03 14:09:27.935: D/dalvikvm(27387): No JNI_OnLoad found in /data/app-lib/com.paala.testhaxe-2/libhypfacebook.so 0x4274e448, skipping init 06-03 14:09:27.935: I/trace(27387): HypFacebook null: 1420285291578270 06-03 14:09:27.935: I/trace(27387): HypFacebook.hx:61: connect 06-03 14:09:27.945: I/trace(27387): HypFacebook.hx:73: bSessionValid ::: false 06-03 14:09:27.945: I/trace(27387): HypFacebook.hx:78: facebook connect for read 06-03 14:09:28.120: I/trace(27387): HypFacebook.hx:90: bSessionValid ::: false 06-03 14:09:28.125: I/trace(27387): Java_fr_hyperfiction_HypFacebook_onFBEvent 06-03 14:09:28.125: I/trace(27387): HypFacebook.hx:304: _onEvent ::: OPENING - - 06-03 14:09:28.125: I/trace(27387): HypFacebook.hx:337: pas connu 06-03 14:09:28.125: I/trace(27387): HypFacebook.hx:344: OPENING?? 06-03 14:09:28.545: D/FacebookSDK.WebDialog(27387): Webview loading URL: https://m.facebook.com/dialog/oauth?display=touch&client_id=1420285291578270&scope=public_profile&type=user_agent&redirect_uri=fbconnect%3A%2F%2Fsuccess 06-03 14:09:33.875: D/FacebookSDK.WebDialog(27387): Redirect URL: https://m.facebook.com/login.php?skip_api_login=1&api_key=1420285291578270&signed_next=1&next=https%3A%2F%2Fm.facebook.com%2Fv2.0%2Fdialog%2Foauth%3Fredirect_uri%3Dfbconnect%253A%252F%252Fsuccess%26display%3Dtouch%26scope%3Dpublic_profile%26type%3Duser_agent%26client_id%3D1420285291578270%26ret%3Dlogin&cancel_uri=fbconnect%3A%2F%2Fsuccess%3Ferror%3Daccess_denied%26error_code%3D200%26error_description%3DPermissions%2Berror%26error_reason%3Duser_denied&display=touch&_rdr 06-03 14:09:33.880: D/FacebookSDK.WebDialog(27387): Webview loading URL: https://m.facebook.com/login.php?skip_api_login=1&api_key=1420285291578270&signed_next=1&next=https%3A%2F%2Fm.facebook.com%2Fv2.0%2Fdialog%2Foauth%3Fredirect_uri%3Dfbconnect%253A%252F%252Fsuccess%26display%3Dtouch%26scope%3Dpublic_profile%26type%3Duser_agent%26client_id%3D1420285291578270%26ret%3Dlogin&cancel_uri=fbconnect%3A%2F%2Fsuccess%3Ferror%3Daccess_denied%26error_code%3D200%26error_description%3DPermissions%2Berror%26error_reason%3Duser_denied&display=touch&_rdr
06-03 14:10:27.435: D/FacebookSDK.WebDialog(27387): Webview loading URL: https://m.facebook.com/login.php?auth_token=65f938e1bc50f7c37030dc0937b89194&skip_api_login=1&signed_next=1&next=https%3A%2F%2Fm.facebook.com%2Fv2.0%2Fdialog%2Foauth%3Fredirect_uri%3Dfbconnect%253A%252F%252Fsuccess%26display%3Dtouch%26scope%3Dpublic_profile%26type%3Duser_agent%26client_id%3D1420285291578270%26ret%3Dlogin&refsrc=https%3A%2F%2Fm.facebook.com%2Flogin.php&app_id=1420285291578270&refid=9 06-03 14:10:29.145: D/FacebookSDK.WebDialog(27387): Redirect URL: https://m.facebook.com/v2.0/dialog/oauth?redirect_uri=fbconnect%3A%2F%2Fsuccess&display=touch&scope=public_profile&type=user_agent&client_id=1420285291578270&ret=login&ext=1401797430&hash=AeZmbnrEGp7_dU2N&refsrc=https%3A%2F%2Fm.facebook.com%2Flogin.php&refid=9&_rdr#_=_ 06-03 14:10:29.145: D/FacebookSDK.WebDialog(27387): Webview loading URL: https://m.facebook.com/v2.0/dialog/oauth?redirect_uri=fbconnect%3A%2F%2Fsuccess&display=touch&scope=public_profile&type=user_agent&client_id=1420285291578270&ret=login&ext=1401797430&hash=AeZmbnrEGp7_dU2N&refsrc=https%3A%2F%2Fm.facebook.com%2Flogin.php&refid=9&_rdr#_=_ 06-03 14:10:31.640: D/FacebookSDK.WebDialog(27387): Webview loading URL: https://m.facebook.com/v2.0/dialog/oauth/confirm After I press confirm (YOU ALREADY HAVE CONFIRMED HAXEFLIXEL AS AN APP)
No new messages
the mainactivity.java exported looks like: Is it normal? package com.paala.testhaxe;
import android.os.Bundle;
public class MainActivity extends org.haxe.lime.GameActivity { }
In facebook settings i have: Package name: com.paala.testhaxe Class name: MainActivity
I think I finally managed to move forward: I replaced MainActivity.java from here: C:\HaxeToolkit\haxe\openfl\lime\openfl-native\1,2,0\templates\android
with the one provided by extension. I replaced nme with lime inside file and now the request event is fired. I think you should modify the java file in haxe branch and update the read me file
Now if I try to post a score by using:
// Make a request to the Facebook Graph API
function graphApi( ) : Void {
var h = new Hash
06-03 15:00:23.275: I/trace(2040): HypFacebook.hx:304: _onEvent ::: GRAPH_REQUEST_ERROR - /100000604711569/scores - {HttpStatus: 400, errorCode: 2500, errorType: OAuthException, errorMessage: The global ID 100000604711569 is not allowed. Please use the application specific ID instead.}
After research I found that I need to get a my user id specific from app. manage to find it out with fb.call( GRAPH_REQUEST("/me") );
Now how to I make posts with scores like the one in this link?: https://developers.facebook.com/docs/games/scores
Now how to I make posts with scores like the one in this link?: https://developers.facebook.com/docs/games/scores
I think you don't, these post are automatically triggered by Facebook when you set a user score.
Hello, I followed the USAGE section of the read me and I manage to setup the facebook app. Now I need to make the app to request publish permissions and to be able to post something like "I made 100 score on app "bla bla" .Link to app";
Thank you.