Solved

Title in Facebook appears with HTML chars

Posted on 2014-01-21
3
287 Views
Last Modified: 2014-01-21
With my PHP script I'm posting in Facebook timeline. Everything fine as long as I'm posting in English. Trying to post in language with special characters (Greek in this case) I'm getting the Title/Link in HTML character set (see the attachment).

I used:
$fb_title = htmlentities($title, ENT_QUOTES, 'UTF-8');
$fb_summary = htmlentities($bodytext, ENT_QUOTES, 'UTF-8');

Open in new window

and the message appeared ok. The title also appeared ok when I appended it to the message. But when the title is the link, it appears with characters like α etc etc.
timeline-greek.jpg
0
Comment
Question by:NickTERiS
  • 2
3 Comments
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 500 total points
Comment Utility
Looks like FB is making the same translation you are.  They've probably had some issues with people who did not know that you need to entitize output before sending it to the browser, or perhaps with people who did not understand character sets.  This is a security issue; if you don't escape the output you're at risk of JavaScript injection and a resulting attack on the client machine.  Facebook cannot afford to become an attack vector.

Please see: http://www.laprbass.com/RAY_temp_nickteris.php

<?php // RAY_temp_nickteris.php
error_reporting(E_ALL);

// IF YOU ALREADY HAVE ENTITIES
$title = '&Alpha;&delta;&omega;&sigma;';
echo $title;

// AND YOU ENTITIZE AGAIN...
$fb_title = htmlentities($title, ENT_QUOTES, 'UTF-8');
echo $fb_title;

Open in new window

Executive summary: Let Facebook do the entitize process and leave it out of your code.  You might want to include a prominent comment explaining why you're not using the traditional and expected escape sequence.
0
 

Author Comment

by:NickTERiS
Comment Utility
This is that I've already did :) But really appreciate your help.
0
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
Thanks for the points and thanks for using EE, ~Ray
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now