Serialized PHP Array Help

[ad_1]

Howdy team,

I am running into a problem in creating my WordPress website and hoping you guys can help out.

Basically, the function of the website is to connect to an API (using wpgetapi plugin) and I need to display it as a table. I am using the WPDataTables plugin in order to do that. However, per the wpgetapi plugin instructions ([https://wpgetapi.com/docs/using-with-wpdatatables/]) I need to create a PHP file in my root directory in order to do that. I navigated to my file manager in GoDaddy (hosting website) and wrote a PHP snippet in order to serialize the data. I then needed to connect the URL to WPDataTables in order for it to read the array and create a table out of it. However, I keep getting an error that says “The table has no rows”. I am sure it is not the API connection being the issue, and I cannot figure out if I coded something wrong in PHP or the url path I’m using isn’t working. This is my following PHP Code:

**<?php**
// Initializing the WordPress engine in a stanalone PHP file
include(‘wp-blog-header.php’);
header(“HTTP/1.1 200 OK”); // Forcing the 200 OK header as WP can return 404 otherwise
$data = wpgetapi\_endpoint( ‘banking\_information’, ‘financials’, array(‘debug’ => false) );
$return\_array = array();
if( isset( $data\[‘results’\] ) && is\_array( $data\[‘results’\] ) ) {
// loop through each item in the results array
foreach ( $data\[‘results’\] as $i => $item ) :
$return\_array\[\] = array(
‘Name’ => $item\[‘NAME’\],
‘Certification Number’ => $item\[‘CERT’\],
‘REPDTE’ => $item\[‘REPDTE’\],
‘Assets’ => $item\[‘ASSET’\],
‘Deposits’ => $item\[‘DEP’\] );
endforeach;
}
echo serialize( $return\_array );

\—————————————————————————————————————————————————

& the URL path I used to link it was [https://domainname/rootfilename](https://domainname/rootfilename)

&#x200B;

For the life of me I cannot figure out what is wrong so I’m hoping someone on here can tell me or point me in the right direction. Thank you 🙂

[ad_2]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer