How to get the number of Facebook likes URLs consistently?

I have a URL that can be expressed as HTTP and HTTPS (technically, these are different URLs, but there seems to be agreement that they are β€œthe same”).

In this example, the HTTP URL is redirected to the HTTP address. This happens in many cases, but I use facebook.comas an example.

My goal is to get a "general comment and the number of shares for http://facebook.comor https://facebook.com."

A request using an HTTP URL https://graph.facebook.com/v2.7/http://facebook.com?access_token=XXXXgives us:

  {
    og_object: {
      id: "10151063484068358",
      title: "Welcome to Facebook - Log In, Sign Up or Learn More",
      type: "website",
      updated_time: "2016-08-31T14:49:01+0000"
    },
    share: {
      comment_count: 5252,
      share_count: 115724962
    },
    id: "http://facebook.com"
  }

And using the HTTPS, https://graph.facebook.com/v2.7/https://facebook.com?access_token=XXXX:

  {
    og_object: {
      id: "10151063484068358",
      title: "Welcome to Facebook - Log In, Sign Up or Learn More",
      type: "website",
      updated_time: "2016-08-31T14:49:41+0000"
    },
    share: {
      comment_count: 1348,
      share_count: 115725362
    },
    id: "https://facebook.com"
  }

Using og_object.id, if I request https://graph.facebook.com/v2.7/10151063484068358/likes?summary=true&access_token=XXXX, I get:

{
  summary: {
    total_count: 5890439,
    can_like: false,
    has_liked: false
  }
}

This is completely different.

And using the field engagement https://graph.facebook.com/v2.7/10151063484068358?fields=engagement&access_token=XXXX

{
  engagement: {
    count: 115740062,
    social_sentence: "115M people like this."
  },
  id: "10151063484068358"
}

115740062, , , , ( ).

engagement likes , :

https://graph.facebook.com/v2.7/https://www.co-operativebank.co.uk/?access_token=XXXX 910 :

{
  og_object: {
    id: "10150337668163877",
    description: "The Co-operative Bank provides personal banking services including current accounts, credit cards, online and mobile banking, personal loans, savings and more",
    title: "Personal banking | Online banking | Co-op Bank",
    type: "website",
    updated_time: "2016-08-31T14:07:30+0000"
  },
  share: {
    comment_count: 0,
    share_count: 910
  },
  id: "https://www.co-operativebank.co.uk/"
}

https://graph.facebook.com/v2.7/10150337668163877?fields=engagement&access_token=XXXX 910

{
  engagement: {
    count: 910,
    social_sentence: "910 people like this."
  },
  id: "10150337668163877"
}

https://graph.facebook.com/v2.7/10150337668163877/likes?summary=true&access_token=XXXX .

{
  data: [ ],
  summary: {
    total_count: 0,
    can_like: false,
    has_liked: false
  }
}

, !

:

  • OpenGraph 10151063484068358, , , URL .
  • URL-, -.
  • HTTPS HTTP
  • HTTPS , HTTP
  • 115724962 115725362 , , .

- .

" http://facebook.com https://facebook.com?

- og_object.id 10151063484068358, ?

+4

Source: https://habr.com/ru/post/1653186/


All Articles