Solved

Title in Facebook appears with HTML chars

Posted on 2014-01-21
3
294 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 110

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 39796441
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
ID: 39796729
This is that I've already did :) But really appreciate your help.
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 39796820
Thanks for the points and thanks for using EE, ~Ray
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

685 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