title: Getting 'total_count' from Page Post Likes 'summary' - Facebook PHP SDK (CLOSED)
body: <p>I'm new to PHP and the Facebook PHP SDK and I'm looking to get the <code>'like_count'</code> from the <code>'likes'</code> <code>'summary'</code> of a Facebook page post. My current code contains the following:</p>
  
  <pre><code>$response = $fb-&gt;get('/me/posts?fields=admin_creator,likes.limit(0).summary(true)&amp;limit=30');
  $getLikeCount = $response-&gt;getGraphEdge()-&gt;asArray();
  foreach($getLikeCount as $likekey){
      if(isset($likekey['likes'])){
          var_export($likekey['likes']);
          foreach ($likekey['likes'] as $likekey){
              //echo $likekey['total_count'] . '&lt;br&gt;';
          }
      }
  }
  </code></pre>
  
  <p>The <code>var_export($likekey['likes']);</code> exports blank arrays while <code>var_export($likekey['summary']);</code> returns NULL. However, in the Graph API Explorer, it returns the following:</p>
  
  <pre><code>{
        "admin_creator": {
          "name": "NAME",
          "id": "ID"
        },
        "id": "ID",
        "likes": {
          "data": [
          ],
          "summary": {
            "total_count": 1022,
            "can_like": true,
            "has_liked": false
          }
        }
      },
  </code></pre>
  
  <p>How can I access the <code>'total_count'</code> field because accessing it through my methods of <code>'likes'</code> and '<code>summary'</code> do not work.</p>
  
  <p><strong>EDIT:</strong> Using <code>getGraphEdge()-&gt;asArray();</code> will not work because it does not return the summary array. I would somehow have to get the values from <code>getDecodedBody();</code> or another method. If I use <code>$getLikeCount = $response-&gt;getDecodedBody();</code>, with this code:</p>
  
  <pre><code>foreach($getLikeCount as $key){
      if(isset($key['admin_creator'])){
          echo $key['admin_creator']['name'];
      }
  }
  </code></pre>
  
  <p>It does not return anything. I am using <code>'admin_creator'</code> as an example because it works if <code>$getLikeCount = $response-&gt;getGraphEdge()-&gt;asArray();</code> and doesn't work in my current method however I cannot use this method because I am trying to get the <code>'total_count'</code> field from the <code>'summary'</code> of post <code>'likes'</code> and the <code>'summary'</code> does not show in the array when using the <code>getGraphEdge()</code> method and only shows when using <code>getDecodedBody();</code>. I'm wondering if there's a way to get the values from <code>getDecodedBody()</code> or if there's a workaround to get the <code>total_count</code> field from <code>summary</code>.</p>
  
  <p><strong>ANSWER:</strong>
  Answer can be found below.</p>