Created
December 8, 2021 18:55
-
-
Save raftaar1191/bb5e2b526e5dd01f3e834e18f9934f6b to your computer and use it in GitHub Desktop.
karuna Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get the responce from the data cms | |
*/ | |
function get_responce_data_cms_get( $url ) { | |
$param = array( | |
'timeout' => 30, | |
'headers' => array() | |
); | |
return wp_remote_get( $url, $param ); | |
} | |
/** | |
* Get the responce from the data cms | |
*/ | |
function get_responce_data_cms_post( $url ) { | |
$param = array( | |
'timeout' => 30, | |
'headers' => array() | |
); | |
return wp_remote_post( $url, $param ); | |
} | |
function deepak_testingget_responce_data_cms() { | |
$url = 'https://data.cms.gov/provider-data/api/1/datastore/query?limit=500&offset=0&count=true&results=true&schema=true&keys=true&format=json&rowIds=false'; | |
$responces = get_responce_data_cms_get( $url ); | |
echo '<pre>'; | |
var_dump( $responces['body'] ); | |
echo '</pre>'; | |
$responces = get_responce_data_cms_post( $url ); | |
echo '<pre>'; | |
var_dump( $responces['body'] ); | |
echo '</pre>'; | |
} | |
add_action( 'init', 'deepak_testingget_responce_data_cms', 1000 ); | |
function get_responce_data_cms_print_html() { | |
$responces = get_responce_data_cms_post( $url ); | |
if( ! empty( $responces['body']->result ) ) { | |
echo '<ul>'; | |
$results = $responces['body']->result; | |
foreach ($results as $key => $value) { | |
echo '<li>'; | |
var_dump( $value ); | |
echo '</li>'; | |
} | |
echo '</ul>'; | |
} | |
} | |
add_shortcode( 'custom_data_cms', 'get_responce_data_cms_print_html_shortcode' ); | |
function get_responce_data_cms_print_html_shortcode() { | |
ob_start(); | |
get_responce_data_cms_print_html(); | |
$output = ob_get_contents(); | |
ob_end_clean(); | |
return $output; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment