Created
July 4, 2019 22:21
-
-
Save stefany-newman/7581914cdb8c0c8d9ec587f136d1063f to your computer and use it in GitHub Desktop.
Trucks code
This file contains 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
<?php | |
require 'scripts/functions.php'; | |
$domain_name = domainName(); // Example.com | |
$siteURL = siteURL(); //https://example.com | |
// Message | |
/* | |
AMP boilerplate CORS code and setting the content type as JSON | |
Since all errors / sucess messages will be encoded in JSON | |
*/ | |
header("Access-Control-Allow-Origin: ". | |
str_replace('.', '-',''.$siteURL.'') .".cdn.ampproject.org"); | |
header("AMP-Access-Control-Allow-Source-Origin:$siteURL"); | |
/* Gmail headers */ | |
header("AMP-Access-Control-Allow-Source-Origin:https://mail.google.com"); | |
header("AMP-Access-Control-Allow-Source-Origin: [email protected]"); | |
header("Access-Control-Allow-Origin: https://mail.google.com"); | |
header("Access-Control-Allow-Headers: Amp4Email-Proxy-Assertion"); | |
header("AMP-Access-Control-Allow-Origin: [email protected]"); | |
/* | |
AMP Playground headers | |
*/ | |
/*header("AMP-Access-Control-Allow-Source-Origin: https://playground.amp.dev"); | |
header("Access-Control-Allow-Origin: https://playground.amp.dev"); | |
*/ | |
/* | |
AMP Gmail headers | |
*/ | |
/* header("AMP-Access-Control-Allow-Source-Origin: [email protected]"); | |
header("Access-Control-Allow-Origin: https://amp.gmail.dev"); */ | |
header("Access-Control-Expose-Headers: AMP-Access-Control-Allow-Source-Origin"); | |
header("Access-Control-Allow-Credentials: true"); | |
header("Content-Type: application/json"); | |
/* | |
Check whether message, phone, name and email is filled in | |
Do not send the email if not. And send a JSON string to | |
display the errors on the front end. | |
*/ | |
echo '{ | |
"items": [ | |
{ | |
"pic" : "https://fabulousnewwebsite.com/trucks/truck1.jpg", | |
"truck_name": "2013 Kenworth K270", | |
"price": "20,000.00 USD" | |
}, | |
{ | |
"pic" : "https://fabulousnewwebsite.com/trucks/truck2.jpg", | |
"truck_name": "2014 Kenworth K270", | |
"price": "30,500.00 USD" | |
}, | |
{ | |
"pic" : "https://fabulousnewwebsite.com/trucks/truck3.jpg", | |
"truck_name": "2015 Kenworth K270", | |
"price": "35,500.00 USD" | |
} | |
] | |
}'; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment