Title: JSON Data for wpDataTables
Last modified: August 10, 2021

---

# JSON Data for wpDataTables

 *  Resolved [keithdukella](https://wordpress.org/support/users/keithdukella/)
 * (@keithdukella)
 * [4 years, 10 months ago](https://wordpress.org/support/topic/json-data-for-wpdatatables/)
 * We have a page on our intranet site that has a simple four column data table 
   on it with a data source that come from a JSON data string on another internal
   website. Up until recently everything was working fine but just in the last week
   or so have no data being displayed in the table. We’ve verified that the JSON
   data feed is working.
 * We recently updated our intranet site to force https connections. Now, when going
   to the table setup in the plug-in page and changing the site URL for the data
   feed to use https and saving the page, we receive an error popup that says ‘SSL
   certificate problem: self-signed certificate in certificate chain.’ We have a
   wildcard certificate issued by GoDaddy and it shows the correct certificate chain
   when viewed in the browser.
 * Can you give me any pointers on troubleshooting where the problem might be?
 * Thanks,
 * Keith

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [wpDataTables](https://wordpress.org/support/users/wpdatatables/)
 * (@wpdatatables)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/json-data-for-wpdatatables/#post-14783522)
 * Hi keithdukella,
    Sorry for the inconvenience,
 * For getting data from JSON source we are using curl and if users using SSL they
   have to adopt it. For such cases, we create a hook that you can use in the functions.
   php file of the theme or child theme.
 *     ```
       function filterCURLOptions($data, $ch, $url){
           $new_ch = curl_init();
           $timeout = 5;
           $agent = 'Mozilla/5.0 (Windows NT 6.2; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0';
           curl_setopt($new_ch, CURLOPT_URL, $url);
           curl_setopt($new_ch, CURLOPT_RETURNTRANSFER, 1);
           curl_setopt($new_ch, CURLOPT_SSL_VERIFYHOST, false);
           curl_setopt($new_ch, CURLOPT_SSL_VERIFYPEER, false);
           curl_setopt($new_ch, CURLOPT_CONNECTTIMEOUT, $timeout);
           curl_setopt($new_ch, CURLOPT_USERAGENT, $agent);
           curl_setopt($new_ch, CURLOPT_REFERER, site_url());
           curl_setopt($new_ch, CURLOPT_FOLLOWLOCATION, true);
           $data = curl_exec($ch);
           if (curl_error($ch)) {
               $error = curl_error($ch);
               curl_close($ch);
               throw new Exception($error);
           }
           if (strpos($data, '<title>Moved Temporarily</title>')) {
               throw new Exception(__('wpDataTables was unable to read your Google Spreadsheet, probably it is not published correctly. <br> You can publish it by going to <b>File -> Publish to the web</b> ', 'wpdatatables'));
           }
           $info = curl_getinfo($ch);
           curl_close($ch);
           if ($info['http_code'] === 404) {
               return NULL;
           }
   
           return $data;
       }
       add_filter('wpdatatables_curl_get_data','filterCURLOptions', 10, 3);
       ```
   
 * Let me know is it working.
 * Best regards.
 *  [stirrell42](https://wordpress.org/support/users/stirrell42/)
 * (@stirrell42)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/json-data-for-wpdatatables/#post-14789716)
 * Sorry if I am mistaken but I was having the same issue and the snippet above 
   did not work for me. I believe that `$new_ch` should be consistently used in 
   the code. For example, instead of `$data = curl_exec($ch)`, it should be:
 * `$data = curl_exec($new_ch);`
 * And then `$new_ch` should be used instead of `$ch` throughout the rest of the
   function. I think the issue I was having was that the `$new_ch` option was being
   changed to allow the self-signed certificate but then the curl command was being
   run on the unchanged instance.
 * Again, if I am wrong I apologize! I don’t want to cause confusion.
 *  Plugin Author [wpDataTables](https://wordpress.org/support/users/wpdatatables/)
 * (@wpdatatables)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/json-data-for-wpdatatables/#post-14795583)
 * Hi stirrell42,
 * Yes you are right. I apologize for providing code with those mistake.
 * Here is the right one:
 *     ```
       function filterCURLOptions($data, $ch, $url){
           $new_ch = curl_init();
           $timeout = 5;
           $agent = 'Mozilla/5.0 (Windows NT 6.2; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0';
           curl_setopt($new_ch, CURLOPT_URL, $url);
           curl_setopt($new_ch, CURLOPT_RETURNTRANSFER, 1);
           curl_setopt($new_ch, CURLOPT_SSL_VERIFYHOST, false);
           curl_setopt($new_ch, CURLOPT_SSL_VERIFYPEER, false);
           curl_setopt($new_ch, CURLOPT_CONNECTTIMEOUT, $timeout);
           curl_setopt($new_ch, CURLOPT_USERAGENT, $agent);
           curl_setopt($new_ch, CURLOPT_REFERER, site_url());
           curl_setopt($new_ch, CURLOPT_FOLLOWLOCATION, true);
           $data = curl_exec($new_ch);
           if (curl_error($new_ch)) {
               $error = curl_error($new_ch);
               curl_close($new_ch);
               throw new Exception($error);
           }
           if (strpos($data, '<title>Moved Temporarily</title>')) {
               throw new Exception(__('wpDataTables was unable to read your Google Spreadsheet, probably it is not published correctly. <br> You can publish it by going to <b>File -> Publish to the web</b> ', 'wpdatatables'));
           }
           $info = curl_getinfo($new_ch);
           curl_close($new_ch);
           if ($info['http_code'] === 404) {
               return NULL;
           }
   
           return $data;
       }
       add_filter('wpdatatables_curl_get_data','filterCURLOptions', 10, 3);
       ```
   
 * Thank you for notice.
 * Best regards.
 *  Plugin Author [wpDataTables](https://wordpress.org/support/users/wpdatatables/)
 * (@wpdatatables)
 * [4 years, 9 months ago](https://wordpress.org/support/topic/json-data-for-wpdatatables/#post-14818860)
 * Hi keithdukella,
 * We didn’t receive feedback for a while, so we suppose that our suggestion help
   you out, so we will mark it as resolved.
 * Thank you for understanding
 * Best regards.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘JSON Data for wpDataTables’ is closed to new replies.

 * ![](https://ps.w.org/wpdatatables/assets/icon-128x128.gif?rev=3010404)
 * [wpDataTables - WordPress Data Table, Dynamic Tables & Table Charts Plugin](https://wordpress.org/plugins/wpdatatables/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wpdatatables/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wpdatatables/)
 * [Active Topics](https://wordpress.org/support/plugin/wpdatatables/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wpdatatables/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wpdatatables/reviews/)

## Tags

 * [json](https://wordpress.org/support/topic-tag/json/)
 * [SSL](https://wordpress.org/support/topic-tag/ssl/)

 * 4 replies
 * 3 participants
 * Last reply from: [wpDataTables](https://wordpress.org/support/users/wpdatatables/)
 * Last activity: [4 years, 9 months ago](https://wordpress.org/support/topic/json-data-for-wpdatatables/#post-14818860)
 * Status: resolved