3

I try this code using Facebook graph to get posts from Facebook Page where the posts in Arabic language but the results shown as hexa Here is the code

var client = new WebClient();
string oauthUrl = string.Format("https://graph.facebook.com/oauth/access_token?type=client_cred&client_id={0}&client_secret={1}", "xxxxxxxxx", "xxxxxxxxx");
string accessToken = client.DownloadString(oauthUrl).Split('=')[1];
string pagePosts = client.DownloadString(string.Format("https://graph.facebook.com/ADEN.IT.page/posts?access_token={0}", accessToken));
Response.Write(pagePosts);
ckruczek
  • 2,361
  • 2
  • 20
  • 23

1 Answers1

0

Try

client.Encoding = System.Text.Encoding.UTF8;

before calling client.DownloadString on your facebook page.
Assuming that the return is really getting the correct content.

EDIT:
Looks like you are getting a JSON Response. For that I unfortunately have to refer you to the facebook documentation on how to deserialize the message.
JSON deserialization in c# itself could then look something like this if facebook provides definitions for the Facebook DataObject :

JsonConvert.DeserializeObject<FacebookDataObject>(pagePost);

EDIT 2:
Maybe this can help:
http://facebooksdk.net/
Parsing Json facebook c#

Community
  • 1
  • 1
Uwe Hafner
  • 4,889
  • 2
  • 27
  • 44
  • Try debugging. Take the created string of your string.Format of the facebook link including the accessToken out of the debug window and paste it into a browser. What does the browser show? – Uwe Hafner Oct 08 '15 at 12:40
  • Excuse me what should I add for access token in the browser – Dhoyazan Abdo Oct 08 '15 at 12:47
  • The return value from the line before the downloadString: string accessToken = client.DownloadString(oauthUrl).Split('=')[1]; – Uwe Hafner Oct 08 '15 at 12:51
  • Your browser shows the same result? Can you add the result from the browser in your post? copy&paste? – Uwe Hafner Oct 08 '15 at 12:52
  • { "data": [ { "message": "\u0627\u0639\u062a\u0642\u062f \u0628\u0639\u0636 \u0648\u0627\u0636\u0639\u0648 \u0645\u0646\u0627\u0647\u062c \u0627\u0644\u062a\u0639\u0644\u064a\u0645 \u0627\u0644\u062a\u0642\u0644\u064a\u062f\u064a\u0629 \u0623\u0646 \u0627\u0644\u0645\u0639\u0644\u0648\u0645\u0627\u062a \u0627\u0644\u062a\u064a \u064a\u0643\u062a\u0633\u0628\u0647\u0627 \u0627\u0644\u062a\u0644\u0627\u0645\u064a\u0630 \u062a\u0624\u062f\u0649 \u0625\u0644\u0649 \u062a\u0639\u062f\u064a\u0644 \u0633\u0644\u0648\u0643\u0647\u0645 \u0648\u0647\u0630\u0627 \u062e\u0637\ – Dhoyazan Abdo Oct 08 '15 at 13:09
  • Thats a JSON Response. You probably have to refer to the facebook documentation on how to deserialize it. They most likely provide classes if this is the standard way. The code would look something like this: JsonConvert.DeserializeObject(pagePost); for an easy Json Conversion. – Uwe Hafner Oct 08 '15 at 13:14
  • Thank you for your help and time – Dhoyazan Abdo Oct 08 '15 at 13:17