Cannot get facebook page id from url if it contains dash

时间:2017-05-16 09:24:38

标签: c# facebook facebook-graph-api facebook-sdk-4.x

I have facebook url like https://www.facebook.com/youtube-7270241753/

I need to get id of that page.

I am using Facebook SDK for C#. I have FacebookClient with access token.

dynamic response = await FbClient.GetTaskAsync($"{input.Url.Replace("www", "graph")}?fields=id");

After this request I get next error :

(OAuthException - #803) (#803) Some of the aliases you requested do not exist: youtube-7270241753

I think problem is in dash. When I post url just like https://www.facebook.com/youtube everything works fine.

How can I proceed with dash in url? Should I manually parse id from that type of url?


I resolve this issue maybe not in best way, but...

As I can see there are 3 different url types for fb page:

  • /pages/{pageName}/{pageId}
  • /{pageName}-{pageId}
  • /{pageName}

For first case I just take latest token. For 2nd case - split token by dash and get latest part. And for 3rd - I am using FbClient and from response get page Id.

0 个答案:

没有答案