Exporter
git-svn-id: http://78.47.251.156/svn/dev/sterntours-3@3477 f459cee4-fb09-11de-96c3-f9c5f16c3c76
This commit is contained in:
parent
b75c88bf96
commit
1b8f8389b9
3 changed files with 21 additions and 7 deletions
|
|
@ -102,7 +102,6 @@ class BookingController extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!isset($travelDate))
|
if (!isset($travelDate))
|
||||||
{
|
{
|
||||||
throw $this->createNotFoundException();
|
throw $this->createNotFoundException();
|
||||||
|
|
|
||||||
|
|
@ -175,7 +175,6 @@ class BookingSternToursCrmExporter extends SternToursCrmExporter
|
||||||
}
|
}
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$resp = $this->httpPostAPIv3('create_drafts', [
|
$resp = $this->httpPostAPIv3('create_drafts', [
|
||||||
'travel_program_id' => $tp->getId(),
|
'travel_program_id' => $tp->getId(),
|
||||||
'comfort' => $bookingRequest->getComfort(),
|
'comfort' => $bookingRequest->getComfort(),
|
||||||
|
|
|
||||||
|
|
@ -12,14 +12,19 @@ use Monolog\Logger;
|
||||||
|
|
||||||
abstract class SternToursCrmExporter
|
abstract class SternToursCrmExporter
|
||||||
{
|
{
|
||||||
//const API_URL = 'http://cms-stern-tours.local/api';
|
//auto
|
||||||
|
|
||||||
|
|
||||||
|
const API_URL_LOCAL = 'http://cms-stern-tours.local/api';
|
||||||
const API_URL = 'https://www.cms.stern-tours.net/api';
|
const API_URL = 'https://www.cms.stern-tours.net/api';
|
||||||
|
const API_v3_URL_LOCAL = 'http://crm-stern-tours.local/';
|
||||||
|
const API_v3_URL = 'https://mein.sterntours.de/';
|
||||||
|
|
||||||
const API_KEY = 'f6077389c9ce710e554763a5de02c8ec';
|
const API_KEY = 'f6077389c9ce710e554763a5de02c8ec';
|
||||||
const API_USER_ID = 15; // 'apiuser'
|
const API_USER_ID = 15; // 'apiuser'
|
||||||
const WEBSITE_ID = 1; // 'sterntours.de'
|
const WEBSITE_ID = 1; // 'sterntours.de'
|
||||||
|
|
||||||
//const API_v3_URL = 'http://crm-stern-tours.local/';
|
|
||||||
const API_v3_URL = 'https://mein.sterntours.de/';
|
|
||||||
const API_v3_MAIL = 'info@mein.sterntours.de';
|
const API_v3_MAIL = 'info@mein.sterntours.de';
|
||||||
const API_v3_PASS = '6m9j,v2GE8px<bt75w';
|
const API_v3_PASS = '6m9j,v2GE8px<bt75w';
|
||||||
|
|
||||||
|
|
@ -45,7 +50,12 @@ abstract class SternToursCrmExporter
|
||||||
|
|
||||||
protected final function httpPost($context, $postData = [], $isContextFullUrl = false)
|
protected final function httpPost($context, $postData = [], $isContextFullUrl = false)
|
||||||
{
|
{
|
||||||
$url = $isContextFullUrl ? $context : self::API_URL.'/'. $context .'.json';
|
$baseUrl = self::API_URL;
|
||||||
|
if($_SERVER['HTTP_HOST'] == 'sterntours.local') {
|
||||||
|
$baseUrl = self::API_URL_LOCAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
$url = $isContextFullUrl ? $context : $baseUrl.'/'. $context .'.json';
|
||||||
$auth = base64_encode("star:4w28baV8xEZa0SR4");
|
$auth = base64_encode("star:4w28baV8xEZa0SR4");
|
||||||
$resp = Util::httpPost($url, $postData, ['X-ApiKey: '. self::API_KEY, 'Authorization: Basic '.$auth], true);
|
$resp = Util::httpPost($url, $postData, ['X-ApiKey: '. self::API_KEY, 'Authorization: Basic '.$auth], true);
|
||||||
return [
|
return [
|
||||||
|
|
@ -68,6 +78,11 @@ abstract class SternToursCrmExporter
|
||||||
|
|
||||||
//first - login and get token
|
//first - login and get token
|
||||||
$baseUrl = self::API_v3_URL.'api/';
|
$baseUrl = self::API_v3_URL.'api/';
|
||||||
|
if($_SERVER['HTTP_HOST'] == 'sterntours.local') {
|
||||||
|
$baseUrl = self::API_v3_URL_LOCAL.'api/';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
'email' => self::API_v3_MAIL,
|
'email' => self::API_v3_MAIL,
|
||||||
'password' => self::API_v3_PASS,
|
'password' => self::API_v3_PASS,
|
||||||
|
|
@ -77,7 +92,7 @@ abstract class SternToursCrmExporter
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
curl_setopt($ch, CURLOPT_URL, $baseUrl.'login');
|
curl_setopt($ch, CURLOPT_URL, $baseUrl.'login');
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||||
curl_setopt($ch, CURLOPT_TIMEOUT, 8);
|
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
|
||||||
curl_setopt($ch, CURLOPT_POST, count($data));
|
curl_setopt($ch, CURLOPT_POST, count($data));
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
|
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
|
||||||
|
|
||||||
|
|
@ -96,6 +111,7 @@ abstract class SternToursCrmExporter
|
||||||
curl_setopt($ch, CURLOPT_URL, $baseUrl.'draft/create_drafts_from_booking');
|
curl_setopt($ch, CURLOPT_URL, $baseUrl.'draft/create_drafts_from_booking');
|
||||||
$result = curl_exec($ch);
|
$result = curl_exec($ch);
|
||||||
$r = json_decode($result);
|
$r = json_decode($result);
|
||||||
|
//var_dump($r);
|
||||||
if($r->success) {
|
if($r->success) {
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
return $r->success;
|
return $r->success;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue