How to retrieve page with special characters in page name - facebook

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.

Related

urlread pound sign (#) doesn't work

Trying to read in the pricing lists under pricing information tab:
urlread( ' http://www.cefconnect.com/Details/Summary.aspx?Ticker=KYE#pricing ' )
But in url '#pricing' doesn't help.
Any suggestions?
As already pointed out by Darin, it's no use adding #pricing to the URL. The web page uses client-side techniques to switch between tabs; not something that can be used by urlread.
Summary.aspx always returns all tabs together as one big page. CSS and JavaScript make it look like a collection of tabs, when opened in a web browser.
Use the developer toolbar of your web browser to inspect the web page. For example in Google Chrome, just right-click on the section you are interested in, and select 'inspect element'.
I don't know what you are going to do with the result of urlread, but you'll probably have to do some parsing to distill the information you need from the HTML clutter.
Please note Summary.aspx launches additional HTTP requests to retrieve additional data. Use the 'Network' tab of Chrome's developer toolbar to analyze that behavior. For example, the following request is made when you click 'GO' after adjusting the pricing history filter criteria.
http://www.cefconnect.com/Resources/TableData/?Type=PricingHistory&Cusip=48660P104&param0=1M&param1=06/06/2014
At first, this seems to complicate the whole matter, but it may actually be a great opportunity. You can call urlread with the URL above, and get some data in JSON format, which is far less cluttered than HTML. Adjust the parameters to get different data. I'm not sure what 48660P104 is; it might be an internal representation of KYE. You may want to use an initial HTTP request to Summary.aspx to retrieve that code; you'll notice the webpage is littered with URLs containing the same parameter Cusip.
The # character has a special meaning in an url. It represents the fragment identifier and the value following it is never sent to the server. Only client side javascript can access it. You will need to url encode the value if you want to send it to the server:
urlread( ' http://www.cefconnect.com/Details/Summary.aspx?Ticker=KYE%23pricing ' )
This also stands true for other special characters. You need to properly encode them.

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

Facebook Feed Dialog API how to include a redirect_uri containing a #?

How can I specify a redirect_uri containing a #?
Facebook Feed Dialog API parameters reference
redirect_uri - The URL to redirect to after a person clicks a button
on the dialog. Required when using URL redirection.
This works as expected when the redirect_uri in question is a regular URL, however, when it contains a # it stops working.
When redirect_uri is http://website.com/foo, it redirects to:
https://website.com/foo?post_id=100006935442054_1384656491776519#_=_
Not sure what the trailing #_=_ is for, but it does not cause any issues here.
When redirect_uri is http://website.com/#foo, it redirects to:
https://website.com/?post_id=100006935442054_1384656491776629#_=_
Thus it appear that either the parameters after the # are ignored, or overridden with #_=_
Given that I am working with a single page application, whose routes are driven by the hash fragment, this breaks my ability to deep link within my application.
Any help/ suggestions on how to work around this would be much appreciated!
In your application you can handle query strings as if it was a hash tag, or simply do a redirect.
For example, if your route is http://website.com/#foo, make http://website.com/?hash=foo do the same thing or redirect ?hash=foo to #foo
I'm working on a problem like this right now. The URL to go in redirect_uri and link:
.../xfile.jsp?item=/contests/bhg_homeimprovement/bhg_splashsweeps_win2500_homeimprovement&temp=yes&hid=#HashID#&esrc=nwbhgsweeps072514a
The FB dialog gets an error as is. Encoding the full URL fixes that and does output hashes around "HashID", but the equal sign before it is removed. Adding a 2nd equal sign there will output 2 equal signs, but having just one will output none.
This isn't a complete solution but it does look like hash marks are possible.

Format of External Links on Facebook

I have seen when you visit a profile on FB and click on link provided in
Contact Information --> Website
Facebook first take you to url format mentioned below
http://www.facebook.com/l.php?u=http%3A%2F%2Fwww.nwaonfire.com%2F&h=BAQByDCFo
and then takes you to the site .
My question is why facebook does so, Iam asking because there is a place in my application where iam allowing users to enter website urls.
...and the reason for facebook using the mentioned link instead of linking directly to http://www.nwaonfire.com is that facebook is evil.
They want to know which links are popular, where their users are going and where the link came from.
I also see a format as http://www.facebook.com/l/BAQByDCFo/www.nwaonfire.com where the BAQByDCFo is a hash value.
URL encoding is done so that a second URL can be placed within the first's query string without breaking the original URL. For example, implying directory structure by using the "/" character or breaking out of name value pair by using "&". If you're going to be embedding a URL as a query string parameter, you must encode it first. How you do this will differ depending on the language you're working with but most web based frameworks have a native or library based function to easily do this.

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.