News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

SA Facebook Integration

Started by SMFHacks.com Team, February 12, 2010, 01:36:11 PM

Previous topic - Next topic

SA™

i fault so in sources/facebook/facebookhooks.php
i already had issues with this function breaking the fb_ui publish function with special charactors


public static function facebook_showPub($data){
   
global $txt, $modSettings, $context, $board;
   
self::get_boardsfb('pub_enable',$board);
$doit = false;
 
if(empty($modSettings['fb_app_enabled']))
            return $doit;
   
$cleaned[] = array_map(array("SAFacebookhooks","facebook_htmlspecialchars"), $data);

$cleaned[0]['body'] = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $cleaned[0]['body']);
        $cleaned[0]['body'] = preg_replace('~&#([0-9]+);~e', 'chr("\\1")', $cleaned[0]['body']);
        $trans_tbl = get_html_translation_table(HTML_ENTITIES);
        $trans_tbl = array_flip($trans_tbl);

$cleaned[0]['body'] = strtr($cleaned[0]['body'], $trans_tbl);

$context['fb_publish_subject'] = $cleaned[0]['subject'];
$context['fb_publish_body'] = $cleaned[0]['body'];
$context['fb_publish_href'] = $cleaned[0]['href'];

if(!empty($data['txt_label']))
    $dtxt = $data['txt_label'];
else
    $dtxt = $txt['fb_apub'];
   
if(!empty($data['isPost']) && !empty($context['pub_enable'])){
    $doit = '
    <li class="fbpub_button">
            <a href="javascript:void(0)" onclick="publishStream(\''.$context['fb_publish_subject'].'\',\''.$context['fb_publish_body'].'\',\''.$context['fb_publish_href'].'\');">'.$dtxt.'</a>
        </li>';
    }else{
    $doit = '<a href="javascript:void(0)" onclick="publishStream(\''.$context['fb_publish_subject'].'\',\''.$context['fb_publish_body'].'\',\''.$context['fb_publish_href'].'\'); return false;"><span>'.$dtxt.'</span></a>';
}

return $doit;
}
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

littleone

Quote from: SA™ on February 28, 2012, 11:23:22 PM
hmmm try removing $_SESSION['is_admin_action'] = false; from sources/facebook/facebookadmin.php

No difference.  I click the "Grant Permissions" button, then "OK" and it clicks over to the board index.  No change on the Publisher page at all.  No clue whats up.

SA™

ok gimmie a day or two and ill try to sort it
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

Joseph H

Guys, is there any way that when a use clicks allow a link then is posted to his wall automaticaly? 
Cheap webhosting +24 hours

jimv8673

Trying to use this mod on 2.0.2 with the Box-It theme and it runs completely off the page and only shows half the block ???:(
any ideas???

distante

Quote from: jimv8673 on March 01, 2012, 07:43:15 AM
Trying to use this mod on 2.0.2 with the Box-It theme and it runs completely off the page and only shows half the block ???:(
any ideas???

Yo need to edit the index.template of your theme manually so it can fit where you want.

Cyber™

Quote from: SA™ on February 29, 2012, 05:06:12 PM
@Cyber™ what part doesnt work with urf-8 ? the your friends part?

Both parts. But the one that concerns me more is my part. Is there any solution?
The opinion is like an asshole. Everybody has one.

Joseph H

Hi, it worked. But i wonder if there is a possibility that when a use click allow then a link is automatically posted to his/her wall @SA
Cheap webhosting +24 hours

SA™

Quote from: Cyber™ on March 02, 2012, 08:12:00 AM
Quote from: SA™ on February 29, 2012, 05:06:12 PM
@Cyber™ what part doesnt work with urf-8 ? the your friends part?

Both parts. But the one that concerns me more is my part. Is there any solution?

well if you tell me what my part is i maybe able to help untill then im not playing the guessing game

Quote from: Donnxxl on March 02, 2012, 04:13:27 PM
Hi, it worked. But i wonder if there is a possibility that when a use click allow then a link is automatically posted to his/her wall @SA

it is possible tho it isnt never going to be in the mod
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

Cyber™

Quote from: SA™ on March 02, 2012, 04:56:55 PM
well if you tell me what my part is i maybe able to help untill then im not playing the guessing game

My part means that when I (as forum admin) want to publish certain post to the Facebook, I click on Publish link. Everything works fine, except UTF-8 characters. The same thing happens for regular users who use Serbian as the boart default langugage (I'm using English, but there is no difference, I've tried to switch to Serbian).
The opinion is like an asshole. Everybody has one.

shorepower

Quote from: SA™ on February 29, 2012, 06:00:59 PM
i fault so in sources/facebook/facebookhooks.php
i already had issues with this function breaking the fb_ui publish function with special charactors


public static function facebook_showPub($data){
   
global $txt, $modSettings, $context, $board;
   
self::get_boardsfb('pub_enable',$board);
$doit = false;
 
if(empty($modSettings['fb_app_enabled']))
            return $doit;
   
$cleaned[] = array_map(array("SAFacebookhooks","facebook_htmlspecialchars"), $data);

$cleaned[0]['body'] = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $cleaned[0]['body']);
        $cleaned[0]['body'] = preg_replace('~&#([0-9]+);~e', 'chr("\\1")', $cleaned[0]['body']);
        $trans_tbl = get_html_translation_table(HTML_ENTITIES);
        $trans_tbl = array_flip($trans_tbl);

$cleaned[0]['body'] = strtr($cleaned[0]['body'], $trans_tbl);

$context['fb_publish_subject'] = $cleaned[0]['subject'];
$context['fb_publish_body'] = $cleaned[0]['body'];
$context['fb_publish_href'] = $cleaned[0]['href'];

if(!empty($data['txt_label']))
    $dtxt = $data['txt_label'];
else
    $dtxt = $txt['fb_apub'];
   
if(!empty($data['isPost']) && !empty($context['pub_enable'])){
    $doit = '
    <li class="fbpub_button">
            <a href="javascript:void(0)" onclick="publishStream(\''.$context['fb_publish_subject'].'\',\''.$context['fb_publish_body'].'\',\''.$context['fb_publish_href'].'\');">'.$dtxt.'</a>
        </li>';
    }else{
    $doit = '<a href="javascript:void(0)" onclick="publishStream(\''.$context['fb_publish_subject'].'\',\''.$context['fb_publish_body'].'\',\''.$context['fb_publish_href'].'\'); return false;"><span>'.$dtxt.'</span></a>';
}

return $doit;
}

I have been looking into this and have not found a solution to the problem. I do understand the problem which is that somewhere it the program the byte stream is believed to be ISO-8859-1 instead of UTF-8 and the conversation is wrong (think this is the problem that Cyber has as well)

One thing I have been trying is to add the UTF-8 flag to HTML_ENTITIES as the the default value for PHP versions prior to 5.4 is ISO-8859-1. I'm running PHP 5.3.3 so I thought this was the problem but I have not managed to get it to work.

(for reference see under encoding in the PHP manual http://www.php.net/manual/en/function.htmlentities.php)

Changed two places and added the UTF-8 flag. If I have tried with quotes,without quotes. Not being an PHP coder I have some problems with the semantic of the language.

static function facebook_htmlspecialchars($data){
   
$data = strip_tags($data);
$data = htmlspecialchars(htmlentities($data, ENT_QUOTES, "UTF-8"), ENT_QUOTES, "UTF-8");
return $data;


and once in the code you pointed out earlier

$cleaned[0]['body'] = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $cleaned[0]['body']);
        $cleaned[0]['body'] = preg_replace('~&#([0-9]+);~e', 'chr("\\1")', $cleaned[0]['body']);
        $trans_tbl = get_html_translation_table(HTML_ENTITIES,"UTF-8");
        $trans_tbl = array_flip($trans_tbl);
");


First, any comments on the coding, perhaps I entered the UTF-8 flag incorrectly. If this does not solve the problem there must be another place in the code were the program belives the stream is ISO-8859-1.
Ἐν οἴνῳ ἀλήθεια -- www.finewines.se

SA™

i have a feeling it is this part get_html_translation_table(HTML_ENTITIES); that is the issue

try this find
get_html_translation_table(HTML_ENTITIES);
replace with
self::translation_table_to_utf8(HTML_ENTITIES);

find
public static function facebook_showPub($data){
before add
static function translation_table_to_utf8($arTranslationtable)
    {
        //loop through the array and convert everything both keys and values
        foreach($arTranslationtable as $charkey => $char)
        {
            $charkey = utf8_encode($charkey);
            $arUTFchars[$charkey]= utf8_encode($char);
        }
        return $arUTFchars;
    }


this is untested though so pls back up before trying ill look into it more after work
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

shorepower

Quote from: SA™ on March 03, 2012, 05:46:55 AM
i have a feeling it is this part get_html_translation_table(HTML_ENTITIES); that is the issue

try this find
get_html_translation_table(HTML_ENTITIES);
replace with
self::translation_table_to_utf8(HTML_ENTITIES);

find
public static function facebook_showPub($data){
before add
static function translation_table_to_utf8($arTranslationtable)
    {
        //loop through the array and convert everything both keys and values
        foreach($arTranslationtable as $charkey => $char)
        {
            $charkey = utf8_encode($charkey);
            $arUTFchars[$charkey]= utf8_encode($char);
        }
        return $arUTFchars;
    }


this is untested though so pls back up before trying ill look into it more after work
Thx SA, I will test this tomorrow.  I have a complete setup with a test site, FB etc for test that I use before I take any modification into my main site. Still running rev36 on the main site :)
Ἐν οἴνῳ ἀλήθεια -- www.finewines.se

Joseph H

Thnx SA, I hope u dont mind giving me the knowledge on how to have an app which post a link automatically to a persons wall even if its out of the mod
Cheap webhosting +24 hours

nfh

Hi,
I just finished setting up a website using SMF for the first time. I also installed this SA Facebook Integration addon, hoping to get a seamless integration between Facebook and my forum.

I thought that the "Connect with Facebook" provided a straightforward way to use Facebook authentication for loggin in on the SMF site. Nonetheless, when I click on the "Connect with Facebook" button, after complying with the agreement text, I'm redirected to a registration form which has my username set as "firstname.lastname" and two fields for a password (password + confirmation).

Wasn't is suppose to logon imediately? Or is this registration procedure really necessary while using Connect with Facebook?

Best regards.

SA™

Quote from: shorepower on March 03, 2012, 12:50:29 PM
Quote from: SA™ on March 03, 2012, 05:46:55 AM
i have a feeling it is this part get_html_translation_table(HTML_ENTITIES); that is the issue

try this find
get_html_translation_table(HTML_ENTITIES);
replace with
self::translation_table_to_utf8(HTML_ENTITIES);

find
public static function facebook_showPub($data){
before add
static function translation_table_to_utf8($arTranslationtable)
    {
        //loop through the array and convert everything both keys and values
        foreach($arTranslationtable as $charkey => $char)
        {
            $charkey = utf8_encode($charkey);
            $arUTFchars[$charkey]= utf8_encode($char);
        }
        return $arUTFchars;
    }


this is untested though so pls back up before trying ill look into it more after work
Thx SA, I will test this tomorrow.  I have a complete setup with a test site, FB etc for test that I use before I take any modification into my main site. Still running rev36 on the main site :)

ok it seems just changing

static function facebook_htmlspecialchars($data){
   
$data = strip_tags($data);
$data = htmlspecialchars(htmlentities($data, ENT_QUOTES), ENT_QUOTES);
return $data;
}


to

static function facebook_htmlspecialchars($data){
   
$data = strip_tags($data);
$data = htmlspecialchars(htmlentities($data, ENT_QUOTES, "UTF-8"), ENT_QUOTES, "UTF-8");
return $data;
}


works for me

Quote from: nfh on March 04, 2012, 01:30:53 AM
Hi,
I just finished setting up a website using SMF for the first time. I also installed this SA Facebook Integration addon, hoping to get a seamless integration between Facebook and my forum.

I thought that the "Connect with Facebook" provided a straightforward way to use Facebook authentication for loggin in on the SMF site. Nonetheless, when I click on the "Connect with Facebook" button, after complying with the agreement text, I'm redirected to a registration form which has my username set as "firstname.lastname" and two fields for a password (password + confirmation).

Wasn't is suppose to logon imediately? Or is this registration procedure really necessary while using Connect with Facebook?

Best regards.

what you see if the first register if you ajint synces to fb you only see that part once
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

shorepower

Quote from: SA™ on March 04, 2012, 02:20:37 AM
Quote from: shorepower on March 03, 2012, 12:50:29 PM
Quote from: SA™ on March 03, 2012, 05:46:55 AM
i have a feeling it is this part get_html_translation_table(HTML_ENTITIES); that is the issue

try this find
get_html_translation_table(HTML_ENTITIES);
replace with
self::translation_table_to_utf8(HTML_ENTITIES);

find
public static function facebook_showPub($data){
before add
static function translation_table_to_utf8($arTranslationtable)
    {
        //loop through the array and convert everything both keys and values
        foreach($arTranslationtable as $charkey => $char)
        {
            $charkey = utf8_encode($charkey);
            $arUTFchars[$charkey]= utf8_encode($char);
        }
        return $arUTFchars;
    }


this is untested though so pls back up before trying ill look into it more after work
Thx SA, I will test this tomorrow.  I have a complete setup with a test site, FB etc for test that I use before I take any modification into my main site. Still running rev36 on the main site :)

ok it seems just changing

static function facebook_htmlspecialchars($data){
   
$data = strip_tags($data);
$data = htmlspecialchars(htmlentities($data, ENT_QUOTES), ENT_QUOTES);
return $data;
}


to

static function facebook_htmlspecialchars($data){
   
$data = strip_tags($data);
$data = htmlspecialchars(htmlentities($data, ENT_QUOTES, "UTF-8"), ENT_QUOTES, "UTF-8");
return $data;
}


works for me

Works for me as well, perfekt. Fixed the UTF-8 problem and Swedish characters are now correct. Perhaps it's the same problem Cyber had.

Thx SA, good support as always
Ἐν οἴνῳ ἀλήθεια -- www.finewines.se

SA™

great thanks for testing ill push this to the next update
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

Joseph H

There is something i don't realy understand...  the part for the publisher, and the tokens.

1. Is it possible to post on behalf of my fans from the mod?

2. Whose profile ID is required before the access tokens part in the mod (publisher)

please help me on this small issue of understanding....
Cheap webhosting +24 hours

SA™

1. no the publisher only publishes to you fb page or profile
2.you facebbook profile id
http://samods.github.io/SAChatBar/

Xbox Live: smokerthecheese 360 or xbone
My Work
Piano Movers / Delivery service
QuoteMy allies are dead.
I'm 'bout to be too.
Zombies are chasing me.
F*** it, I'm screwed -___-

Advertisement: