0

I'm writing a Windows store app, and in my DAL i'm getting XML data from a web service. I'm using HTTP GET requests and responses as exposed by the site's API.

I was able to successfully get data from various methods that doesn't require parameters, or gets integer parametrs..

problem started when i had to use string parameters, english strings passed successfully but strings in hebrew don't.

When i use a test form developed by the site's API, entering say "נאפיס" to the textBox, it returns an XML fine, and with a sniffer, i see that the string was encoded to %E3%E9%F7%F1%E9

When building the URI myself from code with the same name, i only get the XML's schema, and i see that the string was encoded to %D7%93%D7%99%D7%A7%D7%A1%D7%99 - meaning URL encoded with UTF-8..

I tryed to encoding to hebrew and decoding back to utf-8, and got this string: ðàôéñ when i put it in a tool like this: http://coderstoolbox.net/string/ i see that if i URL encode that string(ðàôéñ) i will get the desired %F0%E0%F4%E9%F1.

So i sent that string to the api, but it showed up as %C3%B0%C3%A0%C3%B4%C3%A9%C3%B1 ang again only returning the XML's schema without actual data..

Another method i tried is to encode the hebrew word differently. Since WinRT doesn't support "httputility", i had to import it back with a reflector.. must tell you, it was not fun..

I ended up with the encoded "נאפיס" with %u05e0%u05d0%u05e4%u05d9%u05e1 When i use it from a browser like so:

http://new.rest.co.il/WebService/RestWS.asmx/SearchRestsByName?Keyword=%u05e0%u05d0%u05e4%u05d9%u05e1

it works great, get the actual XML data, and in the sniffer, the parameter stays the same(%u05e0%u05d0%u05e4%u05d9%u05e1).

But when i use it from my code, again i get only the schema, and in the sniffer, i see that the string was encoded to this: %25u05e0%25u05d0%25u05e4%25u05d9%25u05e1 meaning it was URL encoded again!

I'm so desperate from this.. I tried about all combinations..

Does anybody have an idea about this? Thanks.

Rupesh Yadav
  • 12,096
  • 4
  • 53
  • 70
Erez
  • 205
  • 3
  • 13

1 Answers1

0

You should json_encode and then json_decode before sending to fb, it does the trick. Here's a PHP example:

$album_details = array(
  'message'=> 'Live photos from our app',                      
  'name'=> $title, // This can be any non-english characters that can be in unicode
  'access_token'=>$pageAccessToken
);

$jsonStr = json_encode($album_details); // THIS IS KEY IN WHATEVER PLATFORM
$decoded_album_settings = json_decode($jsonStr, true); // THIS IS KEY IN WHATEVER PLATFORM

$create_album = $this->facebook->api('/'.$this->facebookPageId.'/albums', 'post', $decoded_album_settings);

The idea was taken from here: https://stackoverflow.com/a/3806967/1200166

Community
  • 1
  • 1
rantebi
  • 61
  • 1
  • 5