Skip to content
This repository was archived by the owner on Jan 13, 2022. It is now read-only.
This repository was archived by the owner on Jan 13, 2022. It is now read-only.

Only "data" key is cast to GraphNode #700

@jonny-no1

Description

@jonny-no1

I'm retrieving a page's ratings including their id by requesting: /v2.8/*PAGE_ID*/ratings?fields=open_graph_story. The response has the following format:

{
  "data": [
    {
      "open_graph_story": {
        "message": "*REVIEW_TEXT*",
        "start_time": "2016-11-08T14:09:42+0000",
        "type": "places.rates",
        "data": {
          "rating": {
            "value": 5,
            "scale": 5
          },
          "review_text": "*REVIEW_TEXT*",
          "language": "en",
          "generic_place": {
            "id": "*PAGE_ID*",
            "title": "*PAGE_NAME*",
            "type": "place",
            "url": "*PAGE_URL*"
          }
        },
        "id": "*REVIEW_ID*"
      }
    },
  ]
}

Each object in the data array has a key id that contains the review's story id. However, it is dropped when the reviews are casted into GraphNode objects:

object(Facebook\GraphNodes\GraphEdge)#1878 (5) {
  ["items":protected]=>
  array(25) {
    [0]=>
    object(Facebook\GraphNodes\GraphNode)#1761 (1) {
      ["items":protected]=>
      array(1) {
        ["open_graph_story"]=>
        object(Facebook\GraphNodes\GraphNode)#1762 (1) {
          ["items":protected]=>
          array(4) {
            ["rating"]=>
            object(Facebook\GraphNodes\GraphNode)#1774 (1) {
              ["items":protected]=>
              array(2) {
                ["value"]=>
                int(5)
                ["scale"]=>
                int(5)
              }
            }
            ["review_text"]=>
            string(928) "*REVIEW_TEXT*"
            ["language"]=>
            string(2) "en"
            ["generic_place"]=>
            object(Facebook\GraphNodes\GraphNode)#1760 (1) {
              ["items":protected]=>
              array(4) {
                ["id"]=>
                string(15) "*PAGE_ID*"
                ["title"]=>
                string(10) "*PAGE_NAME*"
                ["type"]=>
                string(5) "place"
                ["url"]=>
                string(35) "*PAGE_URL*"
              }
            }
          }
        }
      }
    }
  }
}

Responsible is this:

// Sometimes Graph is a weirdo and returns a GraphNode under the "data" key
$data = $data['data'];

Graph is being a weirdo and doesn't include all information under the data key.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions