The reported bug is an error message, "Unable to get application properties. Confirm both apikey and secret."

To anyone seeing this error, I have the following suggestions.

  • Confirm that both the apikey and secret you've provided are correct.
  • See http://bugs.developers.facebook.com/show_bug.cgi?id=4273. Confirm that your libraries from facebook contain the fix described there.
  • Enable devel and fb_devel modules. Reproduce problem and check logs for any helpful messages.
  • Set $conf['fb_debug'] = TRUE; in your settings.php. And enable the redirect page feature of the devel module. Then save the app node again and you'll see some junk at the top of the page showing what calls to the facebook api were made.

I have not reproduced the bug in my own environment. So if anyone can point out what the problem is, I'd be most grateful.

CommentFileSizeAuthor
#48 fb.module.patch466 bytesandrewc.swanson
#2 369176.diff464 bytesDave Cohen

Comments

gemini’s picture

With that particular message on the edit page, error log shows: "Failed to log into facebook app as user fbu_any". Location and referrer URL is http://www.phoenixhomes.com/node/add/fb-app

Dave Cohen’s picture

StatusFileSize
new464 bytes

I don't think that log message is really part of the problem. The attached patch should make it go away. I don't think this patch will affect the root problem, but if you don't mind testing, I'd appreciate it. I still have not reproduced this myself.

gemini’s picture

Dave,

I downloaded latest upgrade yesterday and my code doesn't even match your difference

  if (!isset($cache[$fb_app->apikey])) {
    try {
      $fb = fb_api_init($fb_app, FB_FBU_ANY);
      $props = $fb->api_client->admin_getAppProperties(array_keys($props_map));
    } catch (Exception $e) {

You have an extra condition wrapping the "try{}"

Dave Cohen’s picture

I checked some changes in yesterday. That entire clause, with patch above, is:

  if (!isset($cache[$fb_app->apikey])) {
    if ($fb = fb_api_init($fb_app, FB_FBU_NO_SESSION)) {
      try {
        $props = $fb->api_client->admin_getAppProperties(array_keys($props_map));
      } catch (Exception $e) {
        fb_log_exception($e, t('Failed to get application properties from Facebook'));
      }
      $cache[$fb_app->apikey] = $props;
    }
  }
  else {
    $props = $cache[$fb_app->apikey];
  }
gemini’s picture

Updated - no error message in the logs. Now we need to figure out why there is a problem with the API key :)

Dave Cohen’s picture

I don't think the apikey is the problem. Based on a comment you made in another issue, it looked like facebook's admin_getAppProperties was in fact returning correct information. So the validation could be failing due to a bug in fb_app.module. But from looking I could not tell what the problem is.

butteryak’s picture

I get the same error. checked everything above, made changes to facebook php. my log error only states " Failed to log into facebook app as user fbu_any"......patch(on facebook php) did not seem to make any differance. tried to apply patch to fb_app.module but I get parse error.

Not sure what to do next with this, as I'm still learning, but I'm more than happy to share info, if it's helpful.

socialnicheguru’s picture

i have this problem too. however, there is nothing in my log.

Do I need to submit my app to the directory? I hope not. i am still working on it :)

I put the debug code in:

1. Called facebook.admin.getAppProperties show in php:

{"about_url":"","application_name":"testred","edit_url":"","post_install_url":"","uninstall_url":"","callback_url":"http:\/\/mysite.com","canvas_name":"testred"}

what is used to verify?

I even reset my key.

I would love to get a page up ASAP.

Dave Cohen’s picture

Can someone help me by adding

dpm($fb_app, "fb_app:");

Right after the call to fb_app_get_app_properties($fb_app) in fb_app_validate(), in fb_app.module?

Then reproduce the error and post here the extra debug output (omit the secret). Since I can't reproduce the problem I'd like to see what your data is.

The fact that the facebook debug info shows values like "application_name":"testred" means that your apikey and secret are fine. The error message is misleading.

For a workaround, I suggest disabling fb_app_validate. Just rename it to fb_app_validateXXXX, temporarily. Then, manually set the canvas path, if you're using canvas pages, with something like "UPDATE fb_app SET canvas='YOUR_CANVAS_PATH' where nid=YOUR_APP_NID;" after you save the other settings.

gemini’s picture

Dave,

I got a few things.

1. This is the error that was in the log:

Cannot modify header information - headers already sent by (output started at /var/www/html/sites/all/modules/fb/facebook-platform/php/facebookapi_php5_restlib.php:82) in /var/www/html/sites/all/modules/fb/facebook-platform/php/facebook.php on line 335.

Cannot modify header information - headers already sent by (output started at /var/www/html/sites/all/modules/fb/facebook-platform/php/facebookapi_php5_restlib.php:82) in /var/www/html/sites/all/modules/fb/facebook-platform/php/facebook.php on line 331.

2. This is the object output:

fb_app: => stdClass Object
(
    [label] => fbphx
    [apikey] => 883aee023a434c4b96a02a8011674a7c
    [secret] => xxxx
    [id] => 49329687557
)

Dave Cohen’s picture

The "cannot modify header" error is produced by facebook's debug output. I don't think there's anyway to avoid it, when $conf['fb_debug'] is true.

The call to fb_app_get_app_properties() is supposed to take a reference and add values to it. Can you add another dpm($fb_app, "fb_app_get_properties returning"); to the very end of fb_app_get_app_properties()?

socialnicheguru’s picture

I put it in and this is what I get

fb_app_get_properties returning => stdClass Object
(
[label] => correct label
[apikey] => correct key
[secret] => correct secret
[id] => correct id
[fb_app_data] => what is this
)

label- does fb check this against something in my app?
what is fb_app_data? nothing was returned.

Dave Cohen’s picture

Please change the dpm call to show more values. Try this:

dpm(array('fb_app' => $fb_app, 'props' => $props, 'fb' => $fb, 'cache' => $cache), 'fb_app_get_app_properties values');

Label gives code another way to refer to your app. This is often more convenient than a node id or apikey.

fb_app_data is a serialized blob of data about the app. Settings that dont need an index in the database. Drupal's user object has an analogous data field.

socialnicheguru’s picture

fb_app_get_app_properties values => Array
(
[fb_app] => stdClass Object
(
[label] => test_fb_app_module
[apikey] => correct apikey
[secret] => correct secret key
[id] =>
[fb_app_data] =>
)

[props] => Array
(
[about_url] =>
[application_name] => My test app
[edit_url] =>
[post_install_url] =>
[uninstall_url] =>
[callback_url] => http://mysite.com/mytestapp
[canvas_name] => mytestapp
)

[fb] => Facebook Object
(
[api_client] => FacebookRestClient Object
(
[secret] => correct secret key
[session_key] =>
[api_key] => correct api key
[friends_list] =>
[user] =>
[added] =>
[is_user] =>
[canvas_user] =>
[batch_mode] => 0
[batch_queue:private] =>
[call_as_apikey:private] =>
[use_curl_if_available:private] => 1
[last_call_id] => 1233973968.4928
[server_addr] => http://api.facebook.com/restserver.php
[cur_id] => 1
)

[api_key] => correct api key
[secret] => correct secret key
[generate_session_secret] =>
[session_expires] =>
[fb_params] => Array
(
)

[user] =>
[profile_user] =>
[canvas_user] =>
[base_domain:protected] =>
)

[cache] => Array
(
[Api Key] => Array
(
[about_url] =>
[application_name] => My test app
[edit_url] =>
[post_install_url] =>
[uninstall_url] =>
[callback_url] => http://mysite.com/mytestapp
[canvas_name] => mytestapp
)

)

)

Dave Cohen’s picture

Well, I see the problem now, but I'm still mystified.

In my facebook client, a call to admin_getAppProperties() return a PHP object. But it looks like yours returns an array. Something is really wrong. It will take some investigating to determine just why that is.

In the meantime, try adding $props = (object) $props; right after $props = $fb->api_client->admin_getAppProperties(array_values($props_map)); in fb_app_get_app_properties().

Dave Cohen’s picture

I looked at the code and it seems the method should be returning an array and not an object. I have no idea why on my server its returning an object. Anyone know PHP and json_decode() well enough to tell me why?

Dave Cohen’s picture

What version of PHP are you guys using? I'm using 5.2.7

socialnicheguru’s picture

-bash-3.1$ php -v
PHP 5.2.6 (cli) (built: May 2 2008 16:06:40)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
with Zend Extension Manager v1.2.2, Copyright (c) 2003-2007, by Zend Technologies
with Zend Optimizer v3.3.3, Copyright (c) 1998-2007, by Zend Technologies

socialnicheguru’s picture

recasting $props as an object does not work. I get the debug output
and a white screen

socialnicheguru’s picture

is this supposed to be this way?

function fb_app_validate_fb_app() {
//dpm(func_get_args(), 'fb_app_validate_fb_app');
}

it is used in line 175 of fb_app.module
// Now we define the form elements specific to our node type.

$form['fb_app'] = array('#tree' => TRUE,
'#weight' => -4,
'#validate' => array('fb_app_validate_fb_app' => arra\
y()),
);

I don't know if it has any relevance at all, but I thought I'd ask :)

this is (has potential) to be a kick a#s module! Looking forward to getting it completely working so I can take it through it's paces.

Dave Cohen’s picture

Status: Active » Fixed

Just checked in the fix. props is an array, not an object

socialnicheguru’s picture

Status: Fixed » Active

Upgraded to new version 2/8/09. The change breaks my install. I get the white screen.

http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/fb/fb_app.m...

1. old install that was working
once I replaced the three lines- white screen
once I reverted back- fine (still has original error)
require once was in settings.php file as prescribed

2. clean install
installed and white screen if I put "require once in my settings file".
If i commented it out, then white screen goes away but original error is still there

Dave Cohen’s picture

Status: Active » Fixed

I don't understand the problem you're describing, but it sounds like not the same issue.

Please use the latest version of the modules and submit a new issue describing the white screen problem. Take a look at your apache error log as it probably will have an error everytime you get a white screen.

socialnicheguru’s picture

EDIT UPDATE: THIS IS FIXED!!!!!

The items i got below no longer apply.

Add this to settings.php:
$conf['fb_api_file'] = 'sites/all/modules/fb/facebook-platform/php/facebook.php';
require_once "sites/all/modules/fb/fb_settings.inc";

Now I have a new issue actually related to the overall thread:
Now I get Failed to get application properties from Facebook: Invalid API key 101

I set debug to true in settings.php file per troubleshooting instructions:
: Called facebook.admin.getAppProperties, show Params | XML | SXML | PHP

Array
(
[properties] => ["about_url","application_name","edit_url","post_install_url","uninstall_url","callback_url","canvas_name"]
)

{"about_url":"","application_name":"activelyOUT activeEvents","edit_url":"","post_install_url":"http:\/\/localhost\/beta\/fb_cb\/10781\/fb_app\/event\/post_authorize","uninstall_url":"http:\/\/localhost\/beta\/fb_cb\/10781\/fb_app\/event\/post_remove","callback_url":"http:\/\/localhost\/beta\/fb_cb\/10781\/","canvas_name":"activelyOUTevents"}

I placed this as per #13 above
dpm(array('fb_app' => $fb_app, 'props' => $props, 'fb' => $fb, 'cache' => $cache), 'fb_app_get_app_properties values');

Nothing is filled in... Nothing is being referenced.

fb_app_get_app_properties values => Array
(
[fb_app] => stdClass Object
(
[fb_app_data] =>
)

[props] =>
[fb] => Facebook Object
(
[api_client] => FacebookRestClient Object
(
[secret] =>
[session_key] =>
[api_key] =>
[friends_list] =>
[user] =>
[added] =>
[is_user] =>
[canvas_user] =>
[batch_mode] => 0
[batch_queue:private] =>
[call_as_apikey:private] =>
[use_curl_if_available:private] => 1
[last_call_id] => 1234223574.86
[server_addr] => http://api.facebook.com/restserver.php
)

[api_key] =>
[secret] =>
[generate_session_secret] =>
[session_expires] =>
[fb_params] => Array
(
)

[user] =>
[profile_user] =>
[canvas_user] =>
[base_domain:protected] =>
)

[cache] => Array
(
[] =>
)

)

socialnicheguru’s picture

this is a reply to #22:

Ok.. this is weird. it was a conflict with Og_vocab

PHP Fatal error: Cannot redeclare custom_url_rewrite() in sites/all/modules/og_vocab/og_vocab.module on line 16

http://drupal.org/node/275665

so i just deactivated it.

butteryak’s picture

Noted that this is listed as "fixed" I've been following along a bit, and I've updated to the revised module. But I still have the same issue. Double checked all API,secret, etc. info. still get the "Unable to get application properties. Confirm both apikey and secret." Pardon my ignorance if I've missed something obvious.

Dave Cohen’s picture

butteryak, could be you have the same problem I originally had, described here: http://bugs.developers.facebook.com/show_bug.cgi?id=4351

If that's the case, its not obvious and you're not ignorant. Its another frustrating bug in the facebook api. Check whether your server's php has the json functions built in.

butteryak’s picture

Thanks dave,
noted and appreciate the support. I was thinking this must be somthing obscure as I've been following the posts pretty closely and doing what has been done so far. I'm running this on apache2 with PHP 5.2.4 built on Ubuntu. According to my phpinfo. I have json installed and enabled. So if I'm understanding this correctly. My php installation may be returning an Array in some functions that I may want to be an Object? Or am I backwords in my thinking on that one. If so....whats the fix.

Dave Cohen’s picture

If you have json built into your PHP, the function will return an array and everything should work as expected. Try adding the debug code in comment #13 and post what you see.

butteryak’s picture

this is what I get. Interesting I'm getting nothing for 'props' 'fb' or 'cache'.............

#

fb_app_get_app_properties values => Array
(
[fb_app] => stdClass Object
(
[label] => correct
[apikey] => correct
[secret] => correct
[id] => correct
)

[props] =>
[fb] =>
[cache] =>
)

#

fb_app_get_properties returning => stdClass Object
(
[label] => correct
[apikey] => correct
[secret] => correct
[id] => correct
)

chrisbuck’s picture

Pardon my ignorance, but could someone explain how to change the DPM call, as referenced in #'s 13 and 29? Thanks.

butteryak’s picture

CBFPLC,

Not sure if this will help you or not, check out post #9, it tells you where to put it. open up the fb_app.module and place it (the dpm) right after the fb_app_get_app_properties($fb_app) line in the fb_app_validate() section. hope that helps. next time you submit your facebook application, you should get the debug output.

butteryak

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Dasha_V - old’s picture

Had the same issue.
The fix was - to enable openssl extention for php.

drupal3008’s picture

Version: 5.x-2.x-dev » 6.x-3.0-beta1

I have read the README.txt from top to bottom!

I've searched through all instances of this issue and one of the closed threads said that facebook had fixed the issue, but it is coming up for me.

This is the output of $url for me {"error_code":"104","error_msg":"Incorrect signature","request_args":[{"key":"method","value":"admin.getAppProperties"},{"key":"properties","value":"about_url,application_name,edit_url,authorize_url,uninstall_url,canvas_name,callback_url,connect_url"},{"key":"access_token","value":""},{"key":"api_key","value":"###################"},{"key":"format","value":"json-strings"}]}

I have double checked everything from the API key, secret etc, and still get that problem with this error:

Unable to get application properties. Confirm both apikey and secret.

1) Downloaded latest PHP sdk files
2) Using latest module Beta 1

Ymox’s picture

Subscribing
I'm beginning to think that it could come from something else than Facebook or any fb.module. The latest Facebook API was released to be able to cope with some changes in the OAuth library…
(I had Facebook Connect on a website, with version 6.x-2.0-rc2, and all settings were retrieved without problem – that was last week. But I tried to get these settings once again yesterday, I got disconnected from Drupal – yes, I got the Drupal message "You can't access this page", and I had to reconnect.)

[Edit] (Shall next one to post set "active" again?)

drupal3008’s picture

I was able to use 6.x-2-dev and make it work again, but would rather use the latest version!

Ymox’s picture

Version: 6.x-3.0-beta1 » 6.x-3.0-beta3
Status: Closed (fixed) » Active

Sorry, I did not want to open a new thread, I think there are enough on this already…

I uninstalled the last version I had (3.0-beta1) to install 3.0-beta3. Read scrupulously the readme for this version and applied carefully the instructions that are in.

I have latest version of Facebook PHP SDK in sites/all/libraries/facebook-php-sdk (is there a message displayed if any fb module can't find it?), and to be sure, I put the include "sites/all/libraries/…" line in my settings.php.

Checked thrice. Still same problem.

Could it come from my site, which base_url is like http://www.example.com/subfolder ?

I'm desperate to find a solution, as since I upgraded to version 3, I can't create any new app – and I now can't create the first one either. As it's the only one I currently need…

Thanks in advance

Dave Cohen’s picture

Have you confirmed the apikey and secret are both correct? Didn't paste them into the wrong fields? (is that what you mean by checked thice?)

I assume you've enabled fb_devel.module, checked the logs and status report?

Have you tried the fix from #34?

Which "migrations" do you have enabled on the remote settings?

You don't need to include facebook.php from your settings.php, but it shouldn't hurt either.

Ymox’s picture

I have checked API and secret keys, entered them in corresponding fields, even tried to invert them : in this case, I receive a 101 Error (invalid API key). Also, I tried to reset the secret key.
By checked thrice, I mean that I read as many times the readme, and checked the settings said to set.

Satus report : Drupal for Facebook full green. Drupal for Facebook Devel too. Facebook PHP SDK found.
In the watchdog, nothing.
I can't see anything such as queries to Facebook as you tell I should in the first post!?

OpenSSL is activated on my server.

As to migrations, I left them by defaul, i.-e. everything disabled.

Server conf : dmu28.infomaniak.ch/phpinfo.php (I hope you can access to it without being logged)

Dave Cohen’s picture

Just guessing here... try enabling the first migration. I don't think there is any one "default" I think it depends on when you created the app. More recent apps have more migrations enabled. I think but I'm not sure.

Lately, I enable all 4 of the migrations.

Ymox’s picture

I tried enabling the JSON relative and the secure URL thing migrations : nada.
I set those parameters this morning (~10 am CET), just tried once again (~4:30 pm CET) whenever there just was problem on propagating changes. I don't think I needed to enable the two last ones, as they're made for canvas pages, and I don't use them, but I just enabled those. I shall come and edit here the result, or post if fixed.
Is there somewhere I could see some more debug messages?

Maybe I shall try and use the OAuth library instead of the Drupal module. I'll try that tomorrow.

[Edit] Enablig canvas pages migration settings did not solve the problem.

Dave Cohen’s picture

The modules will write to the watchdog log or to the screen if they have an error. You can always try your apache error log and anywhere else that php might be configured to write it's errors.

Ymox’s picture

Nothing special in the PHP log.

Is it normal that the new Facebook API has only two files in /src, as the one I had before the 7th October had some 4 files and a /jsonwrapper directory?

Dave Cohen’s picture

My copy has these files

[dave@starbuck facebook-php-sdk]$ ls src
facebook.php  fb_ca_chain_bundle.crt

I suggest you step through code in a debugger or run a packet sniffer to see what's actually crossing the network.
I really don't know what's wrong.

Ymox’s picture

Sorry for replying that late.
I have the same files, so that looks OK.
Another user told me it comes from the server configuration, as he experiences the same problem on the same infomaniak.ch host.. I'll be waiting for more info, and come back to give them here.

Dave Cohen’s picture

The comments in #798460: Can't save application on drupal, particularly about the JSON quotes and escaping, might help.

andrewc.swanson’s picture

StatusFileSize
new466 bytes

I am running PHP 5.1.6 and was running into the "Confirm API Key and Secret" error. I was able to resolve the error by removing the quotes around the JSON string returned by facebook. json_decode, at least the extension I am running for PHP 5.1, couldn't handle the enclosing quotes.

I have the latest dev building of Drupal for Facebook and the latest Facebook SDK, as well as all four migrations enabled.

Dave Cohen’s picture

Thanks for sharing. I wonder if json_decode() behaves differently in php 5.2, which is what I'm using.

Anyone else with this problem, please apply that patch and let us know if that fixes it.

bu5hm4nn’s picture

This patch also worked for me, using the 3.0-beta3 version of fb.module, on Debian 4.0 (haven't gotten around to switching yet).

tamerzg’s picture

Version: 6.x-3.0-beta3 » 6.x-3.0-rc1

Still have the same problem with rc1. I tried the patch in #48 but it didn't help.
This is server info: Apache/2.2.15 (Unix) mod_ssl/2.2.15 OpenSSL/0.9.7a DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 mod_jk/1.2.28 PHP/5.2.13

Strangely on my other server it works just fine. This is info from other server, hope it helps:

Apache/1.3.41 (Unix) mod_gzip/1.3.26.1a mod_auth_passthrough/1.8 mod_log_bytes/1.2 mod_bwlimited/1.4 FrontPage/5.0.2.2635.SR1.2 mod_ssl/2.8.31 OpenSSL/0.9.8e-fips-rhel5 PHP-CGI/0.5

tamerzg’s picture

I traced the problem to wrongly installed Open SSL. Recompiling it solved the problem.

Ymox’s picture

Status: Active » Closed (fixed)

Hello everyone,

Replying late due to start of term and end of traineeship, I could apply the patch only today, and it works. I could set the parameters, and get the others from FaceBook without problems.

I set this as fixed, as I was the one who opened this thread again, and unless I'm mistaken, there's no longer an unsolved issue there. If there is, I hope Dave Cohen won't kill you if you set this active.

Dave Cohen’s picture

Category: bug » support
Status: Closed (fixed) » Active

I'll set it back to active, because I don't plan to apply that patch. At least not without knowing some installs need it, while most work fine without it.

Also, its good to have this in the queue so others who have the same problem can find it.

Dave Cohen’s picture

Version: 6.x-3.0-rc1 » 6.x-3.x-dev

I've made the error message more verbose. Also made the form more tolerant, so it will save the data even when this error is encountered (and even when the apikey or secret are wrong).

If you're experiencing this, please update to dev release and report back here what the more verbose error is.