Akh*_*esh 5 php post google-app-engine
如何在PHP中从Appengine发送带有基本身份验证的POST请求?我已经使用HTTP基本身份验证检查了PHP的问题表格POST请求,但解决方案在Appengine环境中无效.
请建议任何解决方法.谢谢.
小智 5
您发布的解决方案使用套接字,只有在启用结算后才能使用套接字(请参阅https://developers.google.com/appengine/docs/php/sockets/).
或者,您可以将file_get_contents与流上下文中设置的"Authorization"标头一起使用(https://developers.google.com/appengine/docs/php/urlfetch/),例如
$context =
array("http"=>
array(
"method" => "post",
"header" => "Authorization: Basic " . base64_encode($username.':'.$password) . "\r\n",
"content" => $data
)
);
$context = stream_context_create($context);
$result = file_get_contents(url, false, $context);
Run Code Online (Sandbox Code Playgroud)