Social buttons not working in joomla articles

Rate this topic: Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.Evaluations: 1, 1.00 on the average.1.00 out of 6 based on 1 vote(s)
GK User
Mon Dec 24, 2012 1:18 pm
Reply with quote
Report this post
Live site : http://tourisme.nadorpresse.com

Hi,

I noticed that the social buttons in the articles are weird, example : http://tourisme.nadorpresse.com/nador/v ... nador.html

Says it has 2 305 442 likes while the site is not public yet and cannot use the send nor like buttons wrong url set..

I have the right App ID set in the template's options..

I also noticed a problem with the Social GK5 module in the same site, I've configured the twitter username to @nadorpresse but I still can see the ones coming with the template: NeoJoomla, in_2t, gavickpro..

Any idea how to fix these 2 problems please?
User avatar
Senior Boarder

GK User
Thu Dec 27, 2012 9:58 am
Reply with quote
Report this post
Firebug console shows error from fb script :

FB.init has already been called - this could indicate a problem


and this can be a source of problems. Please for test disable the additional FB modules like "find us on facebook". The Twitter issue is related with tweets visibility in Twitter search, module will show only visible tweets and result you can test here by typing your username https://twitter.com/search/

Why your tweets are not visible ? Solution is here https://support.twitter.com/articles/66018#
User avatar
Platinum Boarder

GK User
Thu Dec 27, 2012 12:19 pm
Reply with quote
Report this post
bkrztuk wrote:Firebug console shows error from fb script :

FB.init has already been called - this could indicate a problem


and this can be a source of problems. Please for test disable the additional FB modules like "find us on facebook". The Twitter issue is related with tweets visibility in Twitter search, module will show only visible tweets and result you can test here by typing your username https://twitter.com/search/

Why your tweets are not visible ? Solution is here https://support.twitter.com/articles/66018#


Hi,

I desactived the "like box" module which is actually "Social GK5", Firebug does not show that error, anymore, but I will get back to that once this like button problem fixed and take a look at it.

The issue with the like button seem to be coming from the "url" set in the code, more specificaly this line:

Code: Select all
<fb:like href="/"  send="true" layout="standard" show_faces="false" width="400" action="like" font="arial" colorscheme="light"></fb:like>


When surfing into the site and reading an article, the FB like button shows a large number of likes like it was referring to another site and not the one you're in, well, that is the case, since FB script actually consider the " href="/" " part as being it own site, as in http://www.facebook.com! Try to click on send or like and then you get to share a FB page, not the actual page you're in!

Problem code is in this file: /templates/gk_publisher/html/com_content/article/default.php

I tried changing that line and setting manually an url, changing this:

Code: Select all
<gavern:social><fb:like href="<?php echo $cur_url; ?>" GK_FB_LIKE_SETTINGS></fb:like></gavern:social>


With this:

Code: Select all
<gavern:social><fb:like href="http://tourisme.nadorpresse.com" GK_FB_LIKE_SETTINGS></fb:like></gavern:social>


Then the problem is "partially" fixed, partially since using the like button in all articles makes you like the same one page set, which is the front page.

Knowing that the problem comes then from the $cur_url variable, checking on the same file we find this:

Code: Select all
// URL for Social API
$cur_url = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
$cur_url = preg_replace('@%[0-9A-Fa-f]{1,2}@mi', '', htmlspecialchars($current_url, ENT_QUOTES, 'UTF-8'));


The first line seem to be OK, but removing the second line, that is supposed to clean the page url's special chars...etc fixes the problem!

My question now is, should we definetly get ride of that line, or fix it to make it do what it is actually supposed to do?

Regards.
User avatar
Senior Boarder

GK User
Thu Dec 27, 2012 12:33 pm
Reply with quote
Report this post
leonabil wrote:
bkrztuk wrote:Firebug console shows error from fb script :

FB.init has already been called - this could indicate a problem


and this can be a source of problems. Please for test disable the additional FB modules like "find us on facebook". The Twitter issue is related with tweets visibility in Twitter search, module will show only visible tweets and result you can test here by typing your username https://twitter.com/search/

Why your tweets are not visible ? Solution is here https://support.twitter.com/articles/66018#


Hi,

I desactived the "like box" module which is actually "Social GK5", Firebug does not show that error, anymore, but I will get back to that once this like button problem fixed and take a look at it.

The issue with the like button seem to be coming from the "url" set in the code, more specificaly this line:

Code: Select all
<fb:like href="/"  send="true" layout="standard" show_faces="false" width="400" action="like" font="arial" colorscheme="light"></fb:like>


When surfing into the site and reading an article, the FB like button shows a large number of likes like it was referring to another site and not the one you're in, well, that is the case, since FB script actually consider the " href="/" " part as being it own site, as in http://www.facebook.com! Try to click on send or like and then you get to share a FB page, not the actual page you're in!

Problem code is in this file: /templates/gk_publisher/html/com_content/article/default.php

I tried changing that line and setting manually an url, changing this:

Code: Select all
<gavern:social><fb:like href="<?php echo $cur_url; ?>" GK_FB_LIKE_SETTINGS></fb:like></gavern:social>


With this:

Code: Select all
<gavern:social><fb:like href="http://tourisme.nadorpresse.com" GK_FB_LIKE_SETTINGS></fb:like></gavern:social>


Then the problem is "partially" fixed, partially since using the like button in all articles makes you like the same one page set, which is the front page.

Knowing that the problem comes then from the $cur_url variable, checking on the same file we find this:

Code: Select all
// URL for Social API
$cur_url = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
$cur_url = preg_replace('@%[0-9A-Fa-f]{1,2}@mi', '', htmlspecialchars($current_url, ENT_QUOTES, 'UTF-8'));


The first line seem to be OK, but removing the second line, that is supposed to clean the page url's special chars...etc fixes the problem!

My question now is, should we definetly get ride of that line, or fix it to make it do what it is actually supposed to do?

Regards.

Well, taking a closer look into that problem second line I figured out what causes the problem, there is a typo!

Code: Select all
$cur_url = preg_replace('@%[0-9A-Fa-f]{1,2}@mi', '', htmlspecialchars($current_url, ENT_QUOTES, 'UTF-8'));


The variable used after 'htmlspecialchars' is $current_url instead of $cur_url..

Modifying that fixes the problem and causes another one, I'm not an expert in regex code but that preg_replace is supposed to cut out any special chars from the url, which is in cases with urls using special chars (just like the case here), a char is being cut from the url will result on a 404 page!

i.e:

<fb:like href="http://tourisme.nadorpresse.com/dcouvrir-nador/a-propos/province-de-nador.html"
(404 page).

Instead of:

<fb:like href="http://tourisme.nadorpresse.com/découvrir-nador/a-propos/province-de-nador.html"


Could anyone help get this line fixed or shall we get ride of it?
User avatar
Senior Boarder

GK User
Thu Dec 27, 2012 12:46 pm
Reply with quote
Report this post
After searching a bit around I found a fix:

Problem line:

Code: Select all
$cur_url = preg_replace('@%[0-9A-Fa-f]{1,2}@mi', '', htmlspecialchars($current_url, ENT_QUOTES, 'UTF-8'));


Fixed line:

Code: Select all
$cur_url = preg_replace("/%([0-9A-Fa-f]{2})/e", "chr(hexdec('\\1'))", htmlspecialchars($cur_url, ENT_QUOTES, 'UTF-8'));


Can we do better than this?
User avatar
Senior Boarder

GK User
Fri Dec 28, 2012 9:25 pm
Reply with quote
Report this post
Probably this is the best solution, I'm only curios why on same pages this preg_repace work properly and on some others wrong. Could you give an example URL where the problem exist ?
User avatar
Platinum Boarder

GK User
Fri Dec 28, 2012 9:28 pm
Reply with quote
Report this post
bkrztuk wrote:Probably this is the best solution, I'm only curios why on same pages this preg_repace work properly and on some others wrong. Could you give an example URL where the problem exist ?

Would you like to see a page with the original code causing problem, is that it?
User avatar
Senior Boarder

GK User
Sun Dec 30, 2012 9:51 pm
Reply with quote
Report this post
No I just want to know the URL to page where you have problem because this cur_url variable is created based on current site URL.
User avatar
Platinum Boarder

GK User
Sun Dec 30, 2012 10:30 pm
Reply with quote
Report this post
bkrztuk wrote:No I just want to know the URL to page where you have problem because this cur_url variable is created based on current site URL.

Hi,

The site url (is stated in the first post) is: http://tourisme.nadorpresse.com

The problem no longer exists since I have modified those problem lines..

Regards.
User avatar
Senior Boarder

GK User
Sat Jan 26, 2013 8:59 am
Reply with quote
Report this post
change it for : JURI::current();
User avatar
Junior Boarder

GK User
Sat Mar 23, 2013 7:20 pm
Reply with quote
Report this post
I'm having all kinds of problems getting the fb share button to work. If I 'like' a post, it shows up in my facebook recent activity box, but nothing I 'share' goes to my facebook wall.

I just downloaded and installed the news template no more than a month ago... is there a newer version I need to install?

TIA for any help.
User avatar
Fresh Boarder

GK User
Tue Mar 26, 2013 7:58 am
Reply with quote
Report this post
The button shows proper amount of likes etc ? If yes it looks like the script is working properly.
User avatar
Platinum Boarder

GK User
Wed Mar 27, 2013 12:29 am
Reply with quote
Report this post
bkrztuk wrote:The button shows proper amount of likes etc ? If yes it looks like the script is working properly.



Yes it does, but when I share the post to facebook, it doesn't post.
User avatar
Fresh Boarder

GK User
Wed Mar 27, 2013 9:56 am
Reply with quote
Report this post
Did you configure the APP ID properly ?
User avatar
Platinum Boarder


cron