【发布时间】:2014-01-03 07:36:42
【问题描述】:
我正在尝试通过 php 发布请求更新 Google 融合表。 URL 在Auth PlayGround 上工作得很好。见下图。对不起!堆栈溢出不允许我发布图片,请使用此链接Image
但是当我使用 php post request file_get_content 尝试相同的操作时,它会出现错误“411 Length Required”。代码要求的长度是多少。显然它不是内容长度,因为在这种情况下它是“零”。
<?php
$url = https://www.googleapis.com/fusiontables/v1/query?sql=INSERT INTO 1f_Z_********bQ-br8g17rFWBknri03fz-EQc (Name, Phone) VALUES ('Anees Hameed', '9895435751')
$Post = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-type: application/json',
'header' => 'GData Version: 3.0',
'header' => 'Authorization: Bearer '.$_Session[access_token]
)
);
$Post= stream_context_create($Post);
$request = file_get_content($url, false, $Post);
?>
如何摆脱这个错误。
【问题讨论】:
-
使用
curl而不是file_get_content。 -
curl is not allowed..我正在使用不允许 curl 的 Google App Engine :(
标签: php google-data-api