Skip to content

Instantly share code, notes, and snippets.

@Stefany93
Created July 4, 2019 22:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Stefany93/7581914cdb8c0c8d9ec587f136d1063f to your computer and use it in GitHub Desktop.
Save Stefany93/7581914cdb8c0c8d9ec587f136d1063f to your computer and use it in GitHub Desktop.
Trucks code
<?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: amp@gmail.dev");
header("Access-Control-Allow-Origin: https://mail.google.com");
header("Access-Control-Allow-Headers: Amp4Email-Proxy-Assertion");
header("AMP-Access-Control-Allow-Origin: amp@gmail.dev");
/*
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: amp@gmail.dev");
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