new chiefsoft
This commit is contained in:
@@ -50,6 +50,53 @@ class BaseController extends Controller
|
||||
// E.g.: $this->session = \Config\Services::session();
|
||||
}
|
||||
|
||||
public function APIcall($method, $url, $data) {
|
||||
// $curl = curl_init();
|
||||
$curl = curl_init($url);
|
||||
switch ($method) {
|
||||
case "GET":
|
||||
$params2 = '';
|
||||
foreach($data as $key2=>$value2)
|
||||
$params2 .= $key2.'='.$value2.'&';
|
||||
|
||||
$params2 = trim($params2, '&');
|
||||
$url = $url.'?'.$params2;// add param to URL
|
||||
log_message('critical', "API URL FINAL =>".$url );
|
||||
//curl_setopt($curl, CURLOPT_FRESH_CONNECT, true);
|
||||
//curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||
//curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
|
||||
break;
|
||||
case "POST":
|
||||
curl_setopt($curl, CURLOPT_POST, 1);
|
||||
if ($data)
|
||||
// curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
|
||||
// curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));
|
||||
break;
|
||||
case "PUT":
|
||||
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
|
||||
if ($data)
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
|
||||
break;
|
||||
}
|
||||
|
||||
curl_setopt($curl, CURLOPT_URL, $url);
|
||||
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
|
||||
'APIKEY: RegisteredAPIkey',
|
||||
'Content-Type: application/json',
|
||||
));
|
||||
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
||||
$result = curl_exec($curl);
|
||||
|
||||
if(!$result) {
|
||||
echo("Connection failure!");
|
||||
}
|
||||
curl_close($curl);
|
||||
return json_decode($result, true);
|
||||
}
|
||||
|
||||
var $template = array(
|
||||
'table_open' => "<table class='table table-sm table-striped table-hover table-bordered table-condensed'>",
|
||||
'thead_open' => '<thead class=\'bg-indigo\'>',
|
||||
|
||||
@@ -14,11 +14,27 @@ class Home extends BaseController
|
||||
}
|
||||
|
||||
public function home2(){
|
||||
return view('main/home');
|
||||
$data = [];
|
||||
return $this->sitePage("home", $data);
|
||||
}
|
||||
|
||||
|
||||
private function sitePage($curr_page, $data){
|
||||
return view('main/header').view('main/home').view('main/footer');
|
||||
}
|
||||
public function home(){
|
||||
return view('site/home');
|
||||
|
||||
$siteData =[];
|
||||
$out = $this->APIcall('GET','https://blogdata.chiefsoft.net/blogdata/chiefsoft',[]); // https://blogdata.chiefsoft.net/
|
||||
$siteData['blogdata'] = $out['payload']['blogdata'];
|
||||
|
||||
$data=array();
|
||||
|
||||
$data["blog_featured"] = $siteData['blogdata'][0];
|
||||
$data["blog_array"] =array_slice( $siteData['blogdata'], 0, 7); // $siteData['blogdata'];
|
||||
|
||||
|
||||
return view('site/home', $data);
|
||||
}
|
||||
public function about(){
|
||||
$data=array();
|
||||
@@ -76,6 +92,15 @@ class Home extends BaseController
|
||||
|
||||
}
|
||||
|
||||
$siteData =[];
|
||||
$out = $this->APIcall('GET','https://blogdata.chiefsoft.net/blogdata/chiefsoft',[]); // https://blogdata.chiefsoft.net/
|
||||
$siteData['blogdata'] = $out['payload']['blogdata'];
|
||||
|
||||
$data=array();
|
||||
|
||||
$data["blog_featured"] = $siteData['blogdata'][0];
|
||||
$data["blog_array"] =array_slice( $siteData['blogdata'], 0, 7); // $siteData['blogdata'];
|
||||
|
||||
|
||||
|
||||
$this->renderSitePage('blog',$data);
|
||||
|
||||
Reference in New Issue
Block a user