Facebook open graph og:image escape whitespace characters - facebook

I have a page with user submitted photo galleries. I'm using the facebook API to share the photos. It shares the page with a query string. When the query string is present, it sets all the open graph properties on the page . This works great except when the image has white space characters on the file name.
I have tried replacing the whitespace characters with '%20' as so
http://example.com/gallery/images/large/this image.jpg
to
http://example.com/gallery/images/large/this%20image.jpg
But the facebook parser doesn't like that either.
Is there a way to scape these characters or am I going to have to go back and change it so that it replaces when the images get uploaded?

Answering your question (being it old), Now (in June-2017) Facebook parser works with whitespace characters when escaped with '%20', hope it would help someone looking for solution.
So, convert whitespace to %20 as depicted below:
http://example.com/gallery/images/large/this image.jpg
to
http://example.com/gallery/images/large/this%20image.jpg
Server side language has pre-defined function for that e.g. rawurlencode in PHP.

I don't think so. The facebook parser doesn't take whitespaces into account. Even if you use a redirect you will have issues later on. So it's better to just adjust your URLs now.

Related

Ignore HTML formatting when publishing articles with Confluence Cloud API

I am trying to publish article on Confluence using REST API.
When I am preparing the article in storage format, I indent the content as if I would HTML code, with newlines and spaces. The problem is that when article gets published all these newlines and spaces are preserved, as if I used <br/> and non-breaking space symbols.
For example, if I send content like this:
<p>First part of paragraph
<ac:link ac:anchor="4b14531b1624f2b">
<ri:page ri:content-title="Test Article"></ri:page>
<ac:plain-text-link-body><![CDATA[link caption]]></ac:plain-text-link-body>
</ac:link>
last part of paragraph.</p>
It is rendered like this on the page:
First part of paragraph
link caption
last part of paragraph.
But I expect this:
First part of paragraph link caption last part of paragraph.
Is it possible to tell confluence to ignore whitespaces as in normal HTML? Maybe there's some setting admins can change?
If I create the page normally through web editor and then get its content by API call, all returned content is on one line. This is stupid.
I never had this problem with previous Confluence servers I worked on.
I am using Confluence Cloud version.

How to create FB likebox with special URL characters

I'm trying to create a like for box my clients FB page:
https://www.facebook.com/pages/Cateringinventardk-alt-til-dit-storkøkken-og-café
I guess that little ø or é is messing it up, I got this error:
*The href parameter must reference a valid Facebook page, but "https://www.facebook.com/pages/Cateringinventardk-alt-til-dit-storkøkken-og-café" is not a valid Facebook page.
Anyone who know how I can prevent that with special url/code?
Thanks in advance!
Jan Joergensen
You could try and specify a url-encoded value for the URL. For the URL you supplied this would be something like this:
https%3A%2F%2Fwww.facebook.com%2Fpages%2FCateringinventardk-alt-til-dit-stork%C3%B8kken-og-caf%C3%A9
I've always used this tool, but any other url-encoding tool should do the same job. You might not need to encode the entire URL but rather only the "problematic" characters. For you that's everything after /pages/.
Cateringinventardk-alt-til-dit-storkøkken-og-café
Would become
Cateringinventardk-alt-til-dit-stork%C3%B8kken-og-caf%C3%A9
^----^ ^----^
encoded ø encoded é
I had to use the full url, not just the page vanity url

Preserving HTML Formating when posting a status update

I'm adding features to our in-house CMS, one of the requests is to be able to post content to the CMS and our Facebook page at the same time. I have the actual posting part working, however, the HTML tags that are embedded in the content do not render in the Facebook status.
I get something like:
<p>hello world</p> instead of the rendered text.
Is there a format that I can convert the html tags to that will preserve at least the line and paragraph breaks?
The API strips any and all HTML from status updates before rendering them. If you want to preserve line breaks, you encode them as you pass them, eg %0A for a line break
https://graph.facebook.com/me/feed?access_token=<ACCESS_TOKEN>&message=Hello%0AWorld!!!

How to retrieve page with special characters in page name

Trying to retrieve general page info using the Facebook graph API using an Jquery/Ajax call. This works flawlessly until I request a page containing special characters or dashes in it's name.
It seems like the special characters are ANSI encoded during the ajax request so the name is malformed and the page cannot be found. I can't find a way though to obviate this.
Example url: https://graph.facebook.com/Musée-de-la-Photographie-Charleroi?access_token=[my_access_token]
Can anybody help me out?
I think you should test different values in contentType parameter. It allows to set char encoding.
Take a look here:
http://api.jquery.com/jQuery.ajax/
It seems like the special characters are ANSI encoded during the ajax request so the name is malformed and the page cannot be found.
No, I don’t think that’s the problem.
As you can see from https://developers.facebook.com/tools/explorer?method=GET&path=18521449287, this page does not have a username set yet – and since it is not accessible via just www.facebook.com/Musée-de-la-Photographie-Charleroi, but only via www.facebook.com/pages/Musée-de-la-Photographie-Charleroi/18521449287 including the page id.
And accordingly, info about the page on the Graph API is only available via the page id as well.
Try using the page_id instead (in this case 131141113604635).
https://graph.facebook.com/131141113604635?access_token=[my_access_token]
You may get this id by opening the page on the browser and pressing Ctrl+U, Ctrl+F and searching for a 'page_id' value.

Facebook Share problem for Non English Urls

We have an arabic website and we are trying to share a Url on face book. The Url looks like
http://www.website.com/ar/شاهدى-عروض-الأزياء-العالمية-بعيون-عربية/موضة/story/75
The problem is that the facebook does not get thumbnails present on the above link.
When we debugged this through fiddler, we found that the url that facebook is trying to access is not the same as given above, this url is like
www.website.com/ar/%c3%98%c2%b4%c3%98%c2%a7%c3%99%e2%80%a1%c3%98%c2%af%c3%99%e2%80%b0-%c3%98%c2%b9%c3%98%c2%b1%c3%99%cb%86%c3%98%c2%b6-%c3%98%c2%a7%c3%99%e2%80%9e%c3%98%c2%a3%c3%98%c2%b2%c3%99%c5%a0%c3%98%c2%a7%c3%98%c2%a1-%c3%98%c2%a7%c3%99%e2%80%9e%c3%98%c2%b9%c3%98%c2%a7%c3%99%e2%80%9e%c3%99%e2%80%a6%c3%99%c5%a0%c3%98%c2%a9-%c3%98%c2%a8%c3%98%c2%b9%c3%99%c5%a0%c3%99%cb%86%c3%99%e2%80%a0-%c3%98%c2%b9%c3%98%c2%b1%c3%98%c2%a8%c3%99%c5%a0%c3%98%c2%a9/%c3%99%e2%80%a6%c3%99%cb%86%c3%98%c2%b6%c3%98%c2%a9/story/75
I need to know what facebook did to the url that it became as shown.
One more thing that i know is that this url is not UTF8 encoded. If the given arabic url is converted to UTF8 then it looks like following and not as above
www.website.com/ar/%D8%B4%D8%A7%D9%87%D8%AF%D9%89-%D8%B9%D8%B1%D9%88%D8%B6-%D8%A7%D9%84%D8%A3%D8%B2%D9%8A%D8%A7%D8%A1-%D8%A7%D9%84%D8%B9%D8%A7%D9%84%D9%85%D9%8A%D8%A9-%D8%A8%D8%B9%D9%8A%D9%88%D9%86-%D8%B9%D8%B1%D8%A8%D9%8A%D8%A9/%D9%85%D9%88%D8%B6%D8%A9/story/75
So i need to know which encoding the face book is using or what facebook is doing to access the following url when we share the url
www.website.com/ar/شاهدى-عروض-الأزياء-العالمية-بعيون-عربية/موضة/story/75
http://www.website.com/ar/شاهدى-عروض-الأزياء-العالمية-بعيون-عربية/موضة/story/75
That's not a URI (or URL). It's an IRI. Unfortunately a lot of software doesn't support IRI directly (including SO, as you can see from the way it has linked only the first part of the address!).
So if you want the link to work everywhere you'll have to write it up as a plain URI with UTF-8-URL-encoded pathnames, as in the last example (%D8%B4...). Browser will usually present the encoded link in the address bar as a nice IRI regardless of the link in the HTML document being plain URI.
%c3%98%c2%b4... is what you get when you take bytes that are UTF-8 encoded and treat them as if they were ISO-8859-1-encoded (and then UTF-8-URL-encoding them again, giving a broken “double UTF-8”). How are you getting the IRI into Facebook? Either there's an interface you're using that you're sending UTF-8 but which expects ISO-8859-1, or it's just a plain old bug on Facebook's part. Either way, you'll have to use the URI version for now.