Thank you dave for this awesome module. You have already stated that you not actively maintaining the module, I will soon join the maintainers crew.

I have successfully installed the module and got everything working until it got to the point where the module had to receive app token from facebook.

When i inputted the app id and the app secret, it returned "Unable to get an application token. Are you sure your ID and Secret are correct ".

i had to dig into the code to know where the error was generated from. fb_admin_application_edit_form_validate() function calls fb_admin_get_app_token() to return the app token but unfortunately the latter function did not return the token, so i tested it and this is what i found.

The facebook endpoint the fb_admin_get_app_token() calls return JSON string that needs to be parsed. Maybe when you were writing the module it return something different.

This is how the code is parsed which unfortunately cannot successfully return the app token.

<?php
if ($http->code == 200 && isset($http->data)) {
    $parse = explode('=', $http->data);
    $token = $parse[1];
    return $token;
  }
?>

So i replaced the bolded part with

<?php
$token = drupal_json_decode($http->data);
    return $token['access_token'];
?>

which returns the app token successfully.

i had to register to post this. Please anybody that can patch this module should do so as i cannot do it considering that i am new to the system. i am going to edit the copy on my installed to reflect this until the patch is made.

the function is found in fb.admin.inc

Thanks.

Comments

mmekut created an issue. See original summary.

mmekut’s picture

Issue summary: View changes
ladybug_3777’s picture

StatusFileSize
new512 bytes

IGNORE

ladybug_3777’s picture

Shoot I uploaded the wrong patch file. Fixing....

ladybug_3777’s picture

StatusFileSize
new658 bytes

IGNORE

ladybug_3777’s picture

ladybug_3777’s picture

IGNORE

ladybug_3777’s picture

ladybug_3777’s picture

StatusFileSize
new673 bytes

Clearly I haven't had enough coffee. I re-checked my patch and the format was slightly different than your fix. Sigh. Hopefully comment #9 will have the correct format now. *face palm" LOL

This one SHOULD be correct and should work (I'm going to test it on my remote server next, seemed to work fine locally though)

ladybug_3777’s picture

The application was added now, but I'm continuing to get errors:

Notice: Undefined index: logo_url in fb_admin_application_edit_form_validate() (line 988 of /var/www/html/sites/all/modules/contrib/fb/fb.admin.inc).
Notice: Undefined index: icon_url in fb_admin_applications_form() (line 762 of /var/www/html/sites/all/modules/contrib/fb/fb.admin.inc).

Also, once I try to set up the Site-Wide default token I am getting....
Notice: Undefined index: access_token in fb_auth_get_token() (line 973 of /var/www/html/sites/all/modules/contrib/fb/fb.module).

Back to work on the fix....

ladybug_3777’s picture

StatusFileSize
new1.12 KB

The token issue is now fixed. New patch attached.

There are additional issues with the logo and icon messages, along with the link that goes out to the facebook post... but those issues are different from this one.

This patch should at least get the module up and running again and posting to FB.

mmekut’s picture

Thank you ladybug for the patch. i appreciate your effort.

ladybug_3777’s picture

No problem mmekut! We'll work together to keep this module running!

socialnicheguru’s picture

Status: Active » Needs review
socialnicheguru’s picture

this worked for me. thank you.

danielveza’s picture

Status: Needs review » Reviewed & tested by the community

Happy with patch #11. Worked well for me.

avpaderno’s picture

Issue tags: -app access token