Phoca Facebook Comments with Phoca Gallery
-
- Phoca Member
- Posts: 12
- Joined: 15 Jan 2011, 17:49
Phoca Facebook Comments with Phoca Gallery
First of all thank you for all your great modules, extension etc. for Joomla. I really love your extensions and most of them are also 1.6 ready (great job).
Now the problem I occur . I just removed JComments as comment system and added your Phoca Facebook Comment module. This is al working great for articles etc. but I also like to activated it for your Phoca Gallery component. But when I do this the comment pop-up only displays: "Facebook Application ID is empty" (See for example: http://www.markinthedark.nl/stuff/photo ... -2010.html).
This seems incorrect to me because it is working in articles (See for example: http://www.markinthedark.nl/news/htc-an ... droid.html). I followed all the instructions of your documentation of this module, maybe I missed something, but I can't find it. Hopefully you can help me out.
Thanks in advance.
Now the problem I occur . I just removed JComments as comment system and added your Phoca Facebook Comment module. This is al working great for articles etc. but I also like to activated it for your Phoca Gallery component. But when I do this the comment pop-up only displays: "Facebook Application ID is empty" (See for example: http://www.markinthedark.nl/stuff/photo ... -2010.html).
This seems incorrect to me because it is working in articles (See for example: http://www.markinthedark.nl/news/htc-an ... droid.html). I followed all the instructions of your documentation of this module, maybe I missed something, but I can't find it. Hopefully you can help me out.
Thanks in advance.
-
- Phoca Member
- Posts: 12
- Joined: 15 Jan 2011, 17:49
Re: Phoca Facebook Comments with Phoca Gallery
Hi,
Just got all working. I saw I missed some steps in the installation guide. sorry about that.
A few questions maybe you can answer?
1. Can I see somewhere who has posted a comment or receive a notification? Because sometimes I have to post a reaction on this. I could not find it in Facebook application. Do you have any idea?
2. I enabled guest posting, but it seems not to work. Any ideas on that?
Mark
Just got all working. I saw I missed some steps in the installation guide. sorry about that.
A few questions maybe you can answer?
1. Can I see somewhere who has posted a comment or receive a notification? Because sometimes I have to post a reaction on this. I could not find it in Facebook application. Do you have any idea?
2. I enabled guest posting, but it seems not to work. Any ideas on that?
Mark
- Jan
- Phoca Hero
- Posts: 48403
- Joined: 10 Nov 2007, 18:23
- Location: Czech Republic
- Contact:
Re: Phoca Facebook Comments with Phoca Gallery
Hi,
you can see the statistics on your facebook application site, but there are no specified users. The comments can be managed on the site where they are displayed.
Guests ... I see but no idea why facebook does not allow it? Maybe this should be a question on facebook developers
Jan
you can see the statistics on your facebook application site, but there are no specified users. The comments can be managed on the site where they are displayed.
Guests ... I see but no idea why facebook does not allow it? Maybe this should be a question on facebook developers
Jan
If you find Phoca extensions useful, please support the project
-
- Phoca Member
- Posts: 12
- Joined: 15 Jan 2011, 17:49
Re: Phoca Facebook Comments with Phoca Gallery
Hi Jan,
I think we misunderstood each other. I know and see that I can manage the facebook comments of an article. But it is a lot of work to go through all articles of the site and see if there is a new comment or not. Isn't there a facebook page that shows you all comments of the application?
I just ask it here to see if you have any idea about this. If you don't i'll ask the Facebook developers.
Mark
I think we misunderstood each other. I know and see that I can manage the facebook comments of an article. But it is a lot of work to go through all articles of the site and see if there is a new comment or not. Isn't there a facebook page that shows you all comments of the application?
I just ask it here to see if you have any idea about this. If you don't i'll ask the Facebook developers.
Mark
-
- Phoca Member
- Posts: 12
- Joined: 15 Jan 2011, 17:49
Re: Phoca Facebook Comments with Phoca Gallery
Hi,
I now found out that with the Facebook API I can resolve all comments of the application ID. But I saw in the Phoca Facebook Comment module that you fill the xid with the next:
Is this a special reason? Because with this XID I should normally be able to link back to the article (I think). Isn't it better to add the article ID or normal URL in here?
For example how I try to get all the comments that have been made through your created application ID. Download this code:
http://www.markinthedark.nl/facebook/facebook-php.rar
If you unpack this you see I extended the example.php of the PHP SDK of Facebook. In this example.php I added a way to print the array of all XIDs of your application ID and also all comments of that application ID.
I think normally with this information it must be possible to create a total view of all comments made through the application id. Could be build as a Joomla administrator module to view all comments on all articles. But to be able to link back to the articles from this I think the XID should be something that can be reused to create the working article link.
I hope you understand my post and meaning.
Mark
I now found out that with the Facebook API I can resolve all comments of the application ID. But I saw in the Phoca Facebook Comment module that you fill the xid with the next:
Code: Select all
$xid = md5('pfc'.$uri->toString());
For example how I try to get all the comments that have been made through your created application ID. Download this code:
http://www.markinthedark.nl/facebook/facebook-php.rar
If you unpack this you see I extended the example.php of the PHP SDK of Facebook. In this example.php I added a way to print the array of all XIDs of your application ID and also all comments of that application ID.
I think normally with this information it must be possible to create a total view of all comments made through the application id. Could be build as a Joomla administrator module to view all comments on all articles. But to be able to link back to the articles from this I think the XID should be something that can be reused to create the working article link.
I hope you understand my post and meaning.
Mark
-
- Phoca Member
- Posts: 12
- Joined: 15 Jan 2011, 17:49
Re: Phoca Facebook Comments with Phoca Gallery
Sorry for all reposting. But I found a nice way to extend your Phoca Facebook Comments module. What I did is the following:
I opened the file "default.php" from the modules folder of Facebook Comments and changed these fields:
To the following fields:
Wat this new XID you can always recalculate the URL of where the comment is in place! For example I created this demo (not completely working yet), but the first test comment is a valid URL back to the article page where the comment is (not yet SEF, but that can be done when it is in Joomla).
http://www.markinthedark.nl/facebook/ex ... mments.php
I can extend this demo with deleting comments from there, link back to the page where the comment is etc. etc. This can then be turned into a Joomla administrator page for the Phoca Facebook Comments. If you are interested in the demo code so far. I replaced the RAR file just a minute ago.
I opened the file "default.php" from the modules folder of Facebook Comments and changed these fields:
Code: Select all
//$option = JRequest::getVar('option', '');
//$view = JRequest::getVar('view', '');
//$xid = md5(JURI::base() . $option . $view) . 'pfc';
$uri = &JFactory::getURI();
$xid = md5('pfc'.$uri->toString());
Code: Select all
$pOption = JRequest::getVar('option');
$pView = JRequest::getVar('view');
$pId = JRequest::getVar('id');
$pItemid = JRequest::getVar('Itemid');
$pCatid = JRequest::getVar('catid');
$xid = urlencode('option='.$pOption.'&view='.$pView.'&id='.$pId.'&catid='.$pCatid.'&Itemid='.$pItemid);
http://www.markinthedark.nl/facebook/ex ... mments.php
I can extend this demo with deleting comments from there, link back to the page where the comment is etc. etc. This can then be turned into a Joomla administrator page for the Phoca Facebook Comments. If you are interested in the demo code so far. I replaced the RAR file just a minute ago.
- Jan
- Phoca Hero
- Posts: 48403
- Joined: 10 Nov 2007, 18:23
- Location: Czech Republic
- Contact:
Re: Phoca Facebook Comments with Phoca Gallery
Hi, thank for this info, did you test it with different SEF options?
If you find Phoca extensions useful, please support the project
-
- Phoca Member
- Posts: 12
- Joined: 15 Jan 2011, 17:49
Re: Phoca Facebook Comments with Phoca Gallery
I did test some different SEF code and untill now it works. The only thing you have to do is that you delete the text after the ":". This is something that gets returned from Joomla.
I will send you a private message through this board with some information. Hopefully you can extend the Phoca Facebook Comments module then with this feature.
***** EDIT *****
Sorry I saw I can't send private message yet. So here some code and explanation:
First you have to adjust your default.php file of the Phoca Facebook Module. Change the following:
To the next code:
As you can see I added a strpos() to the $pId and $pCatID. This is because Joomla is adding the SEF URL behind the ":" for these items. But these can't be stored in the xid as I tested. If you do the URL isn't correct all the time. without the ":" it is correct as I have tested.
The rest of your Phoca Facebook Comments can be left as it is. But you could add an administrator page that allows administrators of Joomla to view all facebook comments made on the website. Here is some example code to do this (not Joomla ready, because I am not really into Joomla administrators code):
Ofcourse you need to change this into Joomla code for an administrator. But I think you did this before . As you can see I add a facebook.php file. This file is from the Facebook PHP SDK which can be downloaded here: https://github.com/facebook/php-sdk/
Also the URL I decode can be set to SEF again in Joomla. If you build a Joomla dmin page for this I believe you can recalculate the SEF URL again as follows: http://docs.joomla.org/Routing
But without it it works also. Please let me know if you will build this admin page. Because to my opinion it is very helpfull to have this option.
I will send you a private message through this board with some information. Hopefully you can extend the Phoca Facebook Comments module then with this feature.
***** EDIT *****
Sorry I saw I can't send private message yet. So here some code and explanation:
First you have to adjust your default.php file of the Phoca Facebook Module. Change the following:
Code: Select all
//$option = JRequest::getVar('option', '');
//$view = JRequest::getVar('view', '');
//$xid = md5(JURI::base() . $option . $view) . 'pfc';
$uri = &JFactory::getURI();
$xid = md5('pfc'.$uri->toString());
Code: Select all
$pOption = JRequest::getVar('option');
$pView = JRequest::getVar('view');
$pId = JRequest::getVar('id');
if ( strpos($pId,':') > 0 ) {
$pId = substr($pId,0,strpos($pId,':'));
}
$pItemid = JRequest::getVar('Itemid');
$pCatid = JRequest::getVar('catid');
if ( strpos($pCatid,':') > 0 ) {
$pCatid = substr($pCatid,0,strpos($pCatid,':'));
}
$xid = urlencode('option='.$pOption.'&view='.$pView.'&id='.$pId.'&catid='.$pCatid.'&Itemid='.$pItemid);
The rest of your Phoca Facebook Comments can be left as it is. But you could add an administrator page that allows administrators of Joomla to view all facebook comments made on the website. Here is some example code to do this (not Joomla ready, because I am not really into Joomla administrators code):
Code: Select all
<?php
session_start();
require '../src/facebook.php';
/* Added variables */
define("APP_ID","999999998693633");
define("APP_SECRET","9999999338e65e5f518c11d93cc19baa");
// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
'appId' => APP_ID,
'secret' => APP_SECRET,
'cookie' => true,
));
$appAccessToken = $facebook->getAccessToken();
$appAccessToken = APP_ID.'|'.APP_SECRET;
?>
<html>
<head>
<title>All facebook comments</title>
<style>
body {
font-family: 'Lucida Grande', Verdana, Arial, sans-serif;
}
h1 a {
text-decoration: none;
color: #3b5998;
}
h1 a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '<?php echo $facebook->getAppId(); ?>',
status : false, // check login status
cookie : false, // enable cookies to allow the server to access the session
xfbml : false // parse XFBML
});
};
(function() {
var e = document.createElement('script');
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
e.async = true;
document.getElementById('fb-root').appendChild(e);
}());
</script>
<h1><a href="comments.php">All Facebook comments</a></h1>
<table>
<tr>
<td>Link</td>
<td>Datum</td>
<td>Naam</td>
<td>Comment</td>
</tr>
<?php
try {
$fql = "SELECT xid, object_id, post_id, fromid, time, text, id, username, reply_xid FROM comment WHERE xid IN (SELECT xid FROM comments_info WHERE app_id=".$facebook->getAppId().")";
$param = array('method' => 'fql.query', 'query' => $fql, 'callback'=> '');
$fqlResult = $facebook->api($param);
for($i = 0; $i < count($fqlResult); $i++) {
echo '<tr>';
echo '<td><a href="http://www.markinthedark.nl/index.php?'.urldecode($fqlResult[$i]["xid"]).'" target="_blank">Goto comment</a></td>';
echo '<td>'.date("d-m-Y H:i:s", $fqlResult[$i]["time"]).'</td>';
try {
$fql2 = "SELECT first_name, last_name, profile_url FROM standard_user_info WHERE uid=".$fqlResult[$i]["fromid"];
$param2 = array('method' => 'fql.query', 'query' => $fql2, 'callback'=> '', 'access_token' => $appAccessToken);
$fqlResult2 = $facebook->api($param2);
if(count($fqlResult2) != 1) {
echo '<td>No user found!</td>';
}
else {
echo '<td><a href="'.$fqlResult2[0]["profile_url"].'" target="_blank">'.$fqlResult2[0]["first_name"].' '.$fqlResult2[0]["last_name"].'</a></td>';
}
} catch (FacebookApiException $e) {
echo '<td>'.$e.'</td>';
}
echo '<td>'.$fqlResult[$i]["text"].'</td>';
echo '</tr>';
}
} catch (FacebookApiException $e) {
echo $e;
}
?>
</table>
</body>
</html>
Also the URL I decode can be set to SEF again in Joomla. If you build a Joomla dmin page for this I believe you can recalculate the SEF URL again as follows: http://docs.joomla.org/Routing
But without it it works also. Please let me know if you will build this admin page. Because to my opinion it is very helpfull to have this option.
- Jan
- Phoca Hero
- Posts: 48403
- Joined: 10 Nov 2007, 18:23
- Location: Czech Republic
- Contact:
Re: Phoca Facebook Comments with Phoca Gallery
Ok
1) thank your for this guide
2) what about limitstart and other parameters in the url?
3) in Phoca Gallery 3, there is implemented new view, maybe this can then be used for displaying the comments in admin:
https://www.phoca.cz/documents/2-phoca-g ... ook-albums
Jan
1) thank your for this guide
2) what about limitstart and other parameters in the url?
3) in Phoca Gallery 3, there is implemented new view, maybe this can then be used for displaying the comments in admin:
https://www.phoca.cz/documents/2-phoca-g ... ook-albums
Jan
If you find Phoca extensions useful, please support the project
-
- Phoca Member
- Posts: 12
- Joined: 15 Jan 2011, 17:49
Re: Phoca Facebook Comments with Phoca Gallery
Jan,
1) No problem. Just like all your modules and components and the licenses you use with them
2) I think the Phoca Facebook Comments will run into URL problems if you add all other params to the XID. Because there are several routing ways to get to a page. If the XID resolves into a different XID because a visitor lands on your page through the search option instead of following the menu, some parameters can be different and not all Facebook comments will be shown. Maybe I am incorrect, I am not a Joomla specalist, neither a Facebook specalist. Just trying to help and improve your already great module. Hopefully you can fill the empty wholes of me knowledge in this.
But to add or get all URI parameters you can do this with the JURI class of Joomla:
http://docs.joomla.org/JURI or http://docs.joomla.org/JURI/getInstance
As I said I am not sure if you can use this as XID because the XID should always be the same to resolve the Facebook Comments of a page.
I thought maybe it is an escape to use the url parameter in the fb:comments tag:
http://developers.facebook.com/docs/ref ... s_(xfbml)/
But then I noticed that this url parameter can't be retrieved from the FQL (bit strange, maybe missing in the Facebook documentation?):
http://developers.facebook.com/docs/ref ... l/comment/
3) I am not sure what you mean by this. I also don't run 1.6 yet. Still a 1.5 user . But the parameters you use for Phoca Gallery 3 seems like reuseable to display all Facebook comments in admin.
Mark
1) No problem. Just like all your modules and components and the licenses you use with them
2) I think the Phoca Facebook Comments will run into URL problems if you add all other params to the XID. Because there are several routing ways to get to a page. If the XID resolves into a different XID because a visitor lands on your page through the search option instead of following the menu, some parameters can be different and not all Facebook comments will be shown. Maybe I am incorrect, I am not a Joomla specalist, neither a Facebook specalist. Just trying to help and improve your already great module. Hopefully you can fill the empty wholes of me knowledge in this.
But to add or get all URI parameters you can do this with the JURI class of Joomla:
http://docs.joomla.org/JURI or http://docs.joomla.org/JURI/getInstance
As I said I am not sure if you can use this as XID because the XID should always be the same to resolve the Facebook Comments of a page.
I thought maybe it is an escape to use the url parameter in the fb:comments tag:
http://developers.facebook.com/docs/ref ... s_(xfbml)/
But then I noticed that this url parameter can't be retrieved from the FQL (bit strange, maybe missing in the Facebook documentation?):
http://developers.facebook.com/docs/ref ... l/comment/
3) I am not sure what you mean by this. I also don't run 1.6 yet. Still a 1.5 user . But the parameters you use for Phoca Gallery 3 seems like reuseable to display all Facebook comments in admin.
Mark