I am getting a protected object returned from the API call to Facebook Ads.
$page = new Page($page_id);
$leadgen_forms = $page->getLeadgenForms();
I am getting the response like this :
FacebookAds\Object\Page
(
[response:protected] => FacebookAds\Http\Response Object
(
[response:protected] => Array
(
[data] => Array
(
MY DATA
)
)
)
)
I have already used used Reflection Class
$reflect=new \ReflectionClass($leadgen_forms);
$properties=$reflect->getProperties('content');
and PtcHandyMan
require_once('PtcHm.php');
PtcHandyMan::register();
$data = PtcHandyMan::getProperty( $leadgen_forms , 'content' );
but I am not able to access the protected property. Is there any way to access the protected property. And also I don't get why facebook is giving the protected response.
This is my whole function
function get_page_forms(){
if (!$this->input->is_ajax_request()) {
exit('No direct script access allowed');
}
$page_id = $_POST['page_id'];
$page_access_token = $_POST['page_access_token'];
Api::init('APPID', 'SECRET KEY', $page_access_token);
$page = new Page($page_id);
$leadgen_forms = $page->getLeadgenForms();
//$reflect=new \ReflectionClass($leadgen_forms);
//$properties=$reflect->getProperties('content');
require_once('PtcHm.php');
PtcHandyMan::register();
$data = PtcHandyMan::getProperty( $leadgen_forms , 'content' );
$allFormsArr = $data['data'];
$count = count($allFormsArr);
$output = '<div class="container">
<table class="table table-responsive table-hover">
<thead>
<tr>
<td>Id</td>
<td>Name</td>
<td>Leads csv file</td>
<td>Status</td>
</tr>
</thead>
<tbody>';
for($i=0; $i<$count; $i++){
$output .= '<tr>
<td>'.$allFormsArr[$i]['id'].'</td>
<td>'.$allFormsArr[$i]['name'].'</td>
<td><a href="'.$allFormsArr[$i]['leadgen_export_csv_url'].'" target="_new">Link</a></td>
<td>'.$allFormsArr[$i]['status'].'</td>
</tr>';
}
$output .= '</tbody>
</table>
</div>';
echo $output;
}