$response = get_web_page1( 'http://arc.sgfclients.com/' . str_replace( 'head_face_pdf', 'head_face_pdf_data', $_SERVER['REQUEST_URI'] ) );
//print_r($response);exit;
/*$response = str_replace( ']', '}', str_replace( '[', '{', $response ) );
$response = preg_replace( "/\r|\n/", "", $response );
$products = json_decode($response);*/
function json_validator($data=NULL) {
//echo $data."
";
if (!empty($data)) {
@json_decode($data);
print_r(json_last_error());
return (json_last_error() === JSON_ERROR_NONE);
}
return false;
}
function get_web_page1($url){
$user_agent='Mozilla/5.0 (Windows NT 6.1; rv:8.0) Gecko/20100101 Firefox/8.0';
$options = array(
CURLOPT_CUSTOMREQUEST =>"GET", //set request type post or get
CURLOPT_POST =>false, //set to GET
CURLOPT_USERAGENT => $user_agent, //set user agent
CURLOPT_COOKIEFILE =>"cookie.txt", //set cookie file
CURLOPT_COOKIEJAR =>"cookie.txt", //set cookie jar
CURLOPT_RETURNTRANSFER => true, // return web page
CURLOPT_HEADER => false, // don't return headers
CURLOPT_FOLLOWLOCATION => true, // follow redirects
CURLOPT_ENCODING => "", // handle all encodings
CURLOPT_AUTOREFERER => true, // set referer on redirect
CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect
CURLOPT_TIMEOUT => 120, // timeout on response
CURLOPT_MAXREDIRS => 10, // stop after 10 redirects
);
$ch = curl_init( $url );
curl_setopt_array( $ch, $options );
$content = curl_exec( $ch );
$err = curl_errno( $ch );
$errmsg = curl_error( $ch );
$header = curl_getinfo( $ch );
curl_close( $ch );
$header['errno'] = $err;
$header['errmsg'] = $errmsg;
$header['content'] = $content;
return $header;
}
$response = str_replace( ']', '}', str_replace( '[', '{', strip_tags($response['content']) ) );
$response = preg_replace('/[[:cntrl:]]/', '', $response);
$response = preg_replace( "/\r|\n/", "", $response );
$response = preg_replace( "/\r\n/", "", $response );
// echo "
----------------------------------------------------------------------------------------------
";
// print_r($response);
// echo "
----------------------------------------------------------------------------------------------
";
// echo (json_validator($response) ? "JSON is Valid" : "JSON is Not Valid");
// print_r(json_decode($response,true));
$products = json_decode($response);
$products = json_decode(json_encode($products), true);
// die();
// print_r($products);exit;
// SETUP ALL VARIABLES
foreach( $products as $product ) :
// TITLE
$vars['title'] = $product['title'];
// DESCRIPTION
$vars['description'] = nl2br( $product['description'] );
// GLASSES OPTIONS
$print_var['options'] = '';
$product_count = 0;
foreach( $product['accessories'] as $option ) :
if( isset( $option['selected'] ) ) :
$vars['images']['main'] = $option['image'];
$varSelected = ' - ('.$option['title'].')';
$featured = true;
endif;
$active = isset( $option['selected'] ) ? ' class="active"' : '';
$print_var['options'] .= '
' . $key . ' | '; endif; endforeach; break; endforeach; $print_var['table'] .= '
' . $cell['value'] . ' | '; endif; endforeach; $print_var['table'] .= '