Topic-icon Custom Opengraph in JFB

Active Subscriptions:

None
13 years 1 month ago #32688 by srisiv
Hi Alex,
As I mentioned in my earlier posts, I've now renewed my subscription and excited to use the latest version. I've few questions that I would like to get clarified.

1) I want to create some custom open graph elements for my site. They are pretty simple ones. The demo video that I saw on your site is nice, but it doesn't explain how to use custom open graph. I want to create some actions and objects for EasyDiscuss and also for one more component. How can I do it?

2) When I use JFBProfile to push content from jomsocial to facebook, how can the users from the frontend disable it when they don't need it? I don't see any option in frontend where user can go and uncheck or disable publishing to Facebook. It would be nice to have the switch along with the Opengraph activity settings menu item.
The topic has been locked.
Support Specialist
13 years 1 month ago #32757 by alzander
Replied by alzander on topic Custom Opengraph in JFB
Sriram,
If you wanted to create a custom button that a user can click for an action like "Enjoyed" for "John enjoyed the discussion" (where discussion is the object), you would do the following:
* Create the Action and Object in the Facebook Open Graph developers area
* Create the 'custom' action and object in Open Graph. You would need to leave the "FB Built-In" un-checked in this case.
* The object is created as a "Custom Object" and in the right hand Query Parameters, you'd need to add the correct URL settings, like:

option=com_easydiscuss
view=discussion

Assuming those values are right, that would make the object apply to all Easy Discuss pages.
* Make sure the action you created is associated to the object you create.
* Then, in the EasyDiscuss template or with a custom HTML module, add the following code to display the "I enjoyed" button:
<a href="javascript:void(0)" onclick="jfbc.opengraph.triggerAction('1',window.location)"><img src="http://site.com/button-image.jpg" /></a>
In the triggerAction call, the '1' is the ID of the Action (found in the Open Graph area of JFBConnect) and window.location would be for the current page. You could alter this to be for a different page (if you were in a blog-type view, for instance) as well. Then, just use an image you'd want to display for the button.

Hope that gets you started and makes sense, but if you have any other questions, just let me know.

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
13 years 1 month ago #32768 by srisiv
Replied by srisiv on topic Custom Opengraph in JFB
Hi Alex,
Thanks for the tutorial. Very much appreciated. However, I'm looking for an action that will trigger when a user submit something. Like I have a component for property listing. When a user submits a listing, I want the action to be triggered. How can this be done?
The topic has been locked.
Active Subscriptions:

None
13 years 1 month ago #32851 by srisiv
Replied by srisiv on topic Custom Opengraph in JFB
Hi Alex,
I tried to play around creating the object and action in FB and creating a custom action and object in JFB. No problems with that. However, I have to include the javascript into a php file. When i tried the below code in my php file, I could see the <a>Whatever I gave</a> in frontend and the javascript is not loading the actions. In other words, when i click on the anchor link, nothing happens.

alzander wrote: <a href="javascript:void(0)" onclick="jfbc.opengraph.triggerAction('1',window.location)"><img src="site.com/button-image.jpg" />

The topic has been locked.
Support Specialist
13 years 1 month ago #32922 by alzander
Replied by alzander on topic Custom Opengraph in JFB
Sriram,
Sorry for the delay in getting back to this. For an automatic action to be posted when a user does something on your site, you'll likely need to create an Open Graph plugin for JFBConnect to integrate with that extension. We have quite a few Open Graph plugins already available that you could use for reference if you want to build that.

The code I gave would only be for a link or button the user would click. When you insert that into a PHP file, you'd simply want to make sure that the code is being echo'd properly. That sounds like the case though, or else you'd get a PHP error.

If you click the link and nothing happens, then I'd suggest looking at the Error Console in your browser which should show you if there are any Javascript errors occurring. Let us know what those are and we can gladly help.

Alternatively, can you post a URL to a page where you've included the code above? Then, we can look at the code on the page and see if we see any issues.

Thanks,
Alex
The topic has been locked.
Active Subscriptions:

None
13 years 1 month ago #32925 by srisiv
Replied by srisiv on topic Custom Opengraph in JFB
Hi Alex,
I don't see any error on the console. This makes me feel that I might have configured things wrongly. Here is what I've done so far:


Facebook Stories
Action name - Submitted
Object name - Listing

JFBConnect OpenGraph Settings:
New Custom Object:
Name - Listing
Object Type - listing
Built in fb object - not checked
Published

URL Query
option=com_rpl
view=propertyshow&pid=.$this->pid


New custom action
Action name: submit
Built in fb object - not checked
Published
Object association - Listing[custom]

And here is the code that I entered in the template file:
<?php
<a href="javascript:void(0)" onclick="jfbc.opengraph.triggerAction('1',window.location)"><?php echo ('Submit to Facebook'); ?></a>
<br />
?>


Snapshots link: www.dropbox.com/sh/jmpzbi5aljbtv9t/BYnfwzvJlb
The topic has been locked.
Support Specialist
13 years 1 month ago #32932 by alzander
Replied by alzander on topic Custom Opengraph in JFB
Sriram,
In the Custom Object settings, you have:
view=propertyshow&pid=.$this->pid
If that's the actual text you put in our configuration settings, that would be wrong. We don't parse PHP in the that block, so we would be looking for a pid that actually equals ".$this->pid", which won't ever happen.

Additionally, can you tell me if you're expecting this to trigger automatically, or are you trying to use a button the user can click to post the action? If you want it automatic, you'll need to create an Open Graph plugin, as noted above.

Also, the images are useful, but without seeing the actual HTML, it's difficult to diagnose what could be going wrong.

Let me know how you're trying to get the action going (button-click, I'm assuming) and the URL we can test on, if possible, and we'll gladly help investigate more.

Thanks,
Alex
The topic has been locked.
Support Specialist
13 years 1 month ago #32933 by alzander
Replied by alzander on topic Custom Opengraph in JFB
Oh, also, in the Query Params box, if you want multiple variables to be looked for, they should be entered like:
view=propertyshow
pid=12
Each variable on a newline, with no & in between.
The topic has been locked.
Active Subscriptions:

None
13 years 1 month ago #33153 by srisiv
Replied by srisiv on topic Custom Opengraph in JFB
Hi Alex,
Very sorry for the delayed response. I was quiet tied up. I'm trying to make the action to execute upon click of a button. When a user fills up a form, the form automatically creates a listing based on his input. I'm thinking of putting a button at the end of the submission process where the user can choose to publish his action to FB.

I understand that the plugin cannot parse PHP code. My form has javascript that actually creates a listing id for whatever input the user types in the form and shows it as a separate page. Therefore, I cannot use something like pid=12, as this is generated by the form. Hence, I tried that PHP code.

I'm not a developer and I'm not well versed with coding (PHP, Javascripts especially). If you could help me with this, it would be of great help.
The topic has been locked.
Support Specialist
13 years 3 weeks ago #33212 by alzander
Replied by alzander on topic Custom Opengraph in JFB
Sriram,
It should be fine if you can't use the pid in the trigger. Basically, what you'd want to do then is to update the Custom Object settings to just be:
option=com_xyz
view=propertyshow
That will make the object work on any page of your component for any pid. So, in other words, you want to make the settings as specific as possible, but if there's a variable that can change (like pid), just leave it out.

Then, add your button to the end page form, like:
<a href="javascript:void(0)" onclick="jfbc.opengraph.triggerAction('1','http://yoursite.com/destination-url')"><img src="http://site.com/button-image.jpg" /></a>
The update there is that the window.location was changed to "yoursite.com/destination-url". Since the user would click the button on one page, but would be referencing your "propertyshow" page, you need to actually specify the 'final' page. The window.location value would have just been for the current page the button was clicked on, which doesn't sound like what you want.

Finally, one little change will be required in JFBConnect that I realized. Please edit the /libraries/sourcecoast/openGraphPlugin.php file. Around line 200, you'll see:
//TODO: Replace this with the behavior framework call used in J2.5+ (after J1.5 support is dropped)
        if ($actionAdded)
Update that to:
//TODO: Replace this with the behavior framework call used in J2.5+ (after J1.5 support is dropped)
        if (true)
That will force the code in that block to execute, which is important for your custom action.

I hope that helps, but if not, let us know. Also, if it doesn't work, at this point, I think we'd need to see an actual URL where your button is so we can test and diagnose what else may be wrong.

Thanks,
Alex
The topic has been locked.