'Need help on Facebook API how to get data from array with multiple fields
$endpointFormat = ENDPOINT_BASE . '{page-id}?fields=about,bio,description,new_like_count,talking_about_count,category,fan_count,link,name,rating_count,website,whatsapp_number,followers_count,country_page_likes,were_here_count,location&access_token={access-token}';
$statsAccountEndpoint = ENDPOINT_BASE . $pageId;
$statParams = array(
array ('fields' => 'about','bio','description','new_like_count', 'talking_about_count','category', 'fan_count', 'link','name','rating_count','website','whatsapp_number','followers_count','country_page_likes','were_here_count','location'),
'access_token' => $singleRow['fbaccesstoken']
);
// add params to endpoint
$statsAccountEndpoint .= '?' . http_build_query( $statParams );
// setup curl
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $statsAccountEndpoint );
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
// make call and get response
$response = curl_exec( $ch );
curl_close( $ch );
$responseArray = json_decode( $response, true );
Printing out responseArray which only shows the name and page id
Just wanting to get the stats of the page im linking, tried with only 1 field variable before and it showed fine. Thanks for your time!
Solution 1:[1]
$statParams = array(
'fields' => 'about,bio,description,new_like_count,talking_about_count,category,fan_count,link,name,rating_count,website,whatsapp_number,followers_count,country_page_likes,were_here_count,location',
);
just had to make it so that everything is in one big '' instead of separate.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | L.Gabriel |


