Ryan
Ryan

Reputation: 1885

PHP: encoding meta data for Facebook

Strangest thing:

I'm trying to get facebook to recognize the "&" sign within the <meta property='og:title' content="data"/> field.

I have content being extracted from a db where I urlencode: & becomes &amp; but facebook doesn't pick up the encoding.. Except, when I just plainly add a &amp; to the code itself, it picks it up.. It seems as though it's specifically having an issue with reading the php conversion of the symbols.

Any idea? Been stuck on this for too long. I've been using the facebook linter to test this.

Upvotes: 1

Views: 957

Answers (2)

dossy
dossy

Reputation: 1679

I recommend using an approach like this:

printf('<meta property="og:description" content="%s" />', strip_tags(htmlentities("data")));

Upvotes: 2

Aaron Anodide
Aaron Anodide

Reputation: 17196

If nobody else gives you an exact fix, I think you might benefit from looking at the raw HTTP traffic. There are lots of tools, the lowest level is wire shark.

Upvotes: 1

Related Questions