Topic-icon Custom Object Error: Action is not associated to the object type

Active Subscriptions:

None
10 years 11 months ago - 10 years 11 months ago #33843 by digitalmediaguy
Hey Alex...

So I have been trying to setup a custom opengraph action (save) and object (diy_project) on my girlfriend's website with JFBConnect 5.0 today and have been receiving the error , "Error: Action is not associated to the object type" all afternoon :-/ I can't figure out why...

I have placed the triggerAction code you provided me with a while ago "jfbc.opengraph.triggerAction('33','www.wherever.com')" into a helper.php file of a plugin I am using... This plugin includes/places "save project" buttons into the k2 itemlist view after each intro text block... So basically next to each read more there is a button that says "save project... Again... It's a k2 category view but the triggerAction() code comes from a plugin that "places" my button into this view....

It's all working ok as far as I can tell... If I inspect with firebug I can see that the jfbc.opengraph.triggerAction() function has the correct information... It has my action id "2" and the correct urls for each corresponding k2 item like so:

onclick="jfbc.opengraph.triggerAction('2','index.php?option=com_k2&view=item&id=986'); "

My problem is that when I click the button to test I ALWAYS receive back "Error: Action is not associated to the object type"

SO... I decided I should test... Maybe I didn't have the object setup correctly in JFBConnect... I decided to make 3 objects each with a different type to test:

1) k2 item type - selected the correct category
2) k2 category type - selected the correct category
3) custom type - played with all sorts of query params (view=itemlist, layout=category, option=com_k2, etc) All of them... None of them...

I then tried associating my action (save) to these different objects with the different types one at a time... None worked... So I tried associating my action with all three object types... No luck... All I ever get back is: Error: Action is not associated to the object type... Am I missing something here?

I have re-done auto-tune... made sure publish_stream is authorized... etc... Everything I can think of :/

NOTE: If I am actually in the k2 item view (rather than the k2 category / itemlist view) I get a different error, "Error: Action is not enabled for this user or user is not logged in via Facebook."...

Thanks for helping Alex!!!

Ryan
Last edit: 10 years 11 months ago by digitalmediaguy.
The topic has been locked.
Active Subscriptions:

None
The topic has been locked.
Active Subscriptions:

None
Hey Alex... Curious if you forgot about this one?... It's a different problem than the long wait times / weird godaddy stuff I was having problems with last week!

This one is on my girlfriends blog... I am trying to setup custom actions so her users can "save" her "DIY Projects"... I was having problems (mentioned above) and was curious if maybe I missed something? Or if you could maybe get me going in the correct direction again?

Thanks again Alex...

Ryan
The topic has been locked.
Support Specialist
Whew! Sorry, yeah, I definitely did miss this one. Thanks for bumping it up!

That error message of "Error: Action is not associated to the object type" is likely coming from JFBConnect. Our error message is actually "Action is not associated to the object type of this page.". It's a language file though, and may have changed at some point.. so I'm assuming that's 'our' error and not something coming back from Facebook.

If that's true, it means that JFBConnect is rejecting triggerAction call before we even are trying to submit to Facebook. All the code for that is in /components/com_jfbconnect/models/opengraphaction.php. Specifically, $action->isAssociatedTo($object) is failing. That call, eventually, gets down to getAssociatedObjects in the same file. So, with all that said, here's what I would do to test:
* Definitely make sure that, in the action settings of JFBConnect, make sure you've checked the box to associate the action with the object
* Make sure that the URL you created is properly getting assigned the Object you created and assigned to the action. To do this:
*** Go to the URL, open the source and check the og:type tag. It should be what you set in the Object in JFBConnect. Try changing the type to something very unique and make sure it updates on the page.
* Try disabling any other objects except the one you want to use and try again.

If everything above is right or doesn't help, there's a few code things to check which can help debug things. In the file above, around line 104, you'll see:
$object = array_shift($objects);
            if ($object && $action->isAssociatedTo($object))
Do a print_r of both $objects and $object. See if your object is in either. It should be in the first place, if not, that's what's wrong and we can help you diagnose it.

If it's in the first position of the objects array, then in the file/function mentioned above, around line 250, you'll see:
$this->db->setQuery('SELECT o.* FROM #__opengraph_action_object ao ' .
                    ' INNER JOIN #__opengraph_object o ON ao.object_id = o.id ' .
                    ' WHERE ao.action_id = ' . $this->id .
                    ' AND o.published = 1');

            $objects = $this->db->loadObjectList();
Do a print_r of $objects there. These are the objects that JFBConnect thinks are associated with the action. Make sure it's in there. If not, then there's a configuration error.

Sorry to spit out a ton of stuff, but figured I'd take things through a few steps since I'm behind on helping you here.. and I know you can tinker :) If anything above is confusing, of course, let us know.

Alex
The topic has been locked.