Last active
May 15, 2017 11:35
-
-
Save matsuo/ef5cb7c98bb494d507731886883bcbc1 to your computer and use it in GitHub Desktop.
ローカルでFileMaker Data APIを使って開発する際に利用するPHPのビルトインサーバー用ルータースクリプト
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 | |
$url = "http://127.0.0.1:3000" . $_SERVER['REQUEST_URI']; | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $url); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
if ($_SERVER['REQUEST_METHOD'] === 'POST') { | |
curl_setopt($ch, CURLOPT_POST, true); | |
} | |
if (in_array($_SERVER['REQUEST_METHOD'], array('PUT', 'DELETE'))) { | |
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $_SERVER['REQUEST_METHOD']); | |
} | |
if (in_array($_SERVER['REQUEST_METHOD'], array('POST', 'PUT'))) { | |
curl_setopt($ch, CURLOPT_POSTFIELDS, file_get_contents("php://input")); | |
} | |
curl_setopt($ch, CURLOPT_HTTPHEADER, array( | |
'Content-Type: ' . $_SERVER['CONTENT_TYPE'], | |
'X-Forwarded-For: ' . $_SERVER['REMOTE_ADDR'], | |
'FM-Data-token: ' . $_SERVER['HTTP_FM_DATA_TOKEN'], | |
)); | |
$html = curl_exec($ch); | |
echo $html; | |
curl_close($ch); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I modified for avoiding "Undefined index" warning.
https://gist.github.com/msyk/422725b678dcd8cbd65bf93ddbb24f12