192 lines
7.8 KiB
PHP
192 lines
7.8 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers;
|
|
|
|
use CodeIgniter\HTTP\RequestInterface;
|
|
use CodeIgniter\API\ResponseTrait;
|
|
|
|
class Myfituser extends BaseController
|
|
{
|
|
use ResponseTrait;
|
|
protected $request;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->request = $request = \Config\Services::request();
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
/* header('Access-Control-Allow-Origin: * ');
|
|
//header("Access-Control-Allow-Origin: http://localhost:9057 ");
|
|
header('Access-Control-Expose-Headers: Access-Control-Allow-Origin');
|
|
header('Access-Control-Allow-Credentials: true ');
|
|
//header("Access-Control-Allow-Headers: Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With");
|
|
header('Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS');
|
|
header('Content-type: application/json');
|
|
|
|
$mBlogData = new \App\Models\myfitBlogData();
|
|
$res1 = $mBlogData->getBlogData([]);
|
|
return $this->response->setJson($res1);*/
|
|
}
|
|
|
|
public function users()
|
|
{
|
|
header('Access-Control-Allow-Origin: *');
|
|
//header("Access-Control-Allow-Origin: http://localhost:9057 ");
|
|
header('Access-Control-Expose-Headers: Access-Control-Allow-Origin');
|
|
//header('Access-Control-Allow-Credentials: true ');
|
|
//header("Access-Control-Allow-Headers: Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With");
|
|
header('Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS');
|
|
header('Content-type: application/json');
|
|
|
|
// what is the endpoint
|
|
$uri = current_url(true);
|
|
$pieces = explode('/', $uri);
|
|
$psc = count($pieces);
|
|
|
|
$endpoint = $psc > 0 ? $pieces[$psc - 1] : '';
|
|
|
|
$endpoints = [
|
|
'account' => ['POST'],
|
|
'login' => ['POST'],
|
|
'reminders' => ['GET'],
|
|
'myfeed' => ['GET'],
|
|
'calendar' => ['GET'],
|
|
'profile' => ['GET'],
|
|
'loginhx' => ['GET'],
|
|
];
|
|
|
|
$res1 = [];
|
|
if (array_key_exists($endpoint, $endpoints)) {
|
|
} else {
|
|
http_response_code(404);
|
|
// tell the user product does not exist
|
|
echo json_encode(['message' => 'Endpoint not found.']);
|
|
}
|
|
// echo "EXYTACT INPUT DATA HERE";
|
|
$raw_json = file_get_contents('php://input');
|
|
$raw_array = json_decode($raw_json, true);
|
|
|
|
switch ($endpoint) {
|
|
case 'login':
|
|
$userAccess = new \App\Models\userAccess();
|
|
$res1 = $userAccess->startLogin($raw_array);
|
|
break;
|
|
case 'account':
|
|
$res = $this->dummyData($raw_array);
|
|
break;
|
|
case 'reminders':
|
|
$myfitUserReminders = new \App\Models\myfitUserReminders();
|
|
$res1 = $myfitUserReminders->readReminders($raw_array);
|
|
break;
|
|
case 'myfeed':
|
|
$res = $this->dummyData($raw_array);
|
|
break;
|
|
case 'calendar':
|
|
$res = $this->dummyData($raw_array);
|
|
break;
|
|
case 'profile':
|
|
$res = $this->dummyData($raw_array);
|
|
break;
|
|
case 'loginhx':
|
|
$myfitHx = new \App\Models\myfitHx();
|
|
$res1 = $myfitHx->readLoginHx($raw_array);
|
|
break;
|
|
}
|
|
|
|
return $this->response->setJson($res1);
|
|
}
|
|
|
|
//this is dummy function to establish the endpoints before real implementations
|
|
private function dummyData($raw_array)
|
|
{
|
|
return [
|
|
'msg' => 'Not implemented yet',
|
|
'raw_data' => $raw_array,
|
|
];
|
|
}
|
|
public function blogdata()
|
|
{
|
|
/* header("Access-Control-Allow-Origin: *");
|
|
//header("x-devicetoken : *");
|
|
//header("Authorization : Token");
|
|
header("Access-Control-Expose-Headers: Access-Control-Allow-Origin");
|
|
header("Access-Control-Allow-Headers: Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With,x-session-id, client_id, x-float-device-location-latitude, x-float-device-location-longitude, x-devicetoken");
|
|
header("Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS");
|
|
header('Content-type: application/json');
|
|
Access-Control-Allow-Origin
|
|
|
|
header1 = ('Access-Control-Allow-Credentials','true')
|
|
header2 = ('Access-Control-Allow-Origin', 'https://serviceview.example.com')
|
|
|
|
*/
|
|
header('Access-Control-Allow-Origin: * ');
|
|
//header("Access-Control-Allow-Origin: http://localhost:9057 ");
|
|
header('Access-Control-Expose-Headers: Access-Control-Allow-Origin');
|
|
header('Access-Control-Allow-Credentials: true ');
|
|
//header("Access-Control-Allow-Headers: Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With");
|
|
header('Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS');
|
|
header('Content-type: application/json');
|
|
|
|
$mBlogData = new \App\Models\myfitBlogData();
|
|
$res1 = $mBlogData->getBlogData([]);
|
|
return $this->response->setJson($res1);
|
|
// $this->setGetReturn(res1);
|
|
}
|
|
|
|
public function country()
|
|
{
|
|
//header("Access-Control-Allow-Origin: http://localhost:9057 ");
|
|
header('Access-Control-Allow-Origin: * ');
|
|
header('Access-Control-Expose-Headers: Access-Control-Allow-Origin');
|
|
header('Access-Control-Allow-Credentials: true ');
|
|
//header("Access-Control-Allow-Headers: Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With");
|
|
header('Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS');
|
|
header('Content-type: application/json');
|
|
|
|
$mCountry = new \App\Models\myfitCountry();
|
|
return $this->response->setJson($mCountry->getSiteCountries([]));
|
|
}
|
|
|
|
public function faq()
|
|
{
|
|
//header("Access-Control-Allow-Origin: http://localhost:9057 ");
|
|
header('Access-Control-Allow-Origin: * ');
|
|
header('Access-Control-Expose-Headers: Access-Control-Allow-Origin');
|
|
header('Access-Control-Allow-Credentials: true ');
|
|
//header("Access-Control-Allow-Headers: Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With");
|
|
header('Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS');
|
|
header('Content-type: application/json');
|
|
|
|
$mFaq = new \App\Models\myfitFaqData();
|
|
return $this->response->setJson($mFaq->getSiteFaq([]));
|
|
}
|
|
|
|
public function pricing()
|
|
{
|
|
//header("Access-Control-Allow-Origin: http://localhost:9057 ");
|
|
header('Access-Control-Allow-Origin: * ');
|
|
header('Access-Control-Expose-Headers: Access-Control-Allow-Origin');
|
|
header('Access-Control-Allow-Credentials: true ');
|
|
//header("Access-Control-Allow-Headers: Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With");
|
|
header('Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS');
|
|
header('Content-type: application/json');
|
|
|
|
$mPricing = new \App\Models\myfitPricing();
|
|
return $this->response->setJson($mPricing->getSitePricing([]));
|
|
}
|
|
|
|
private function setGetReturn($resp)
|
|
{
|
|
header('Access-Control-Allow-Origin: * ');
|
|
//header("Access-Control-Allow-Origin: http://localhost:9057 ");
|
|
header('Access-Control-Expose-Headers: Access-Control-Allow-Origin');
|
|
header('Access-Control-Allow-Credentials: true ');
|
|
//header("Access-Control-Allow-Headers: Cache-Control, Pragma, Origin, Authorization, Content-Type, X-Requested-With");
|
|
header('Access-Control-Allow-Methods: POST, GET, PUT, DELETE, OPTIONS');
|
|
header('Content-type: application/json');
|
|
return $this->response->setJson($resp);
|
|
}
|
|
}
|