[已解决] php 中用 file_get_contents() 提交 xml 请求?
发表于 : 2012-12-26 22:48
我在做一个小 app 可以同步 youtube 的评论。在 google API 的官网说明上,添加 youtube 评论需要提交如下样例的请求:
我搜到一些教程都是用 curl 的。我没有 curl,只能用 file_get_contents() 来做。我不太清楚怎么写 header,代码也不成功。
链接:https://developers.google.com/youtube/2 ... l_commentsPOST /feeds/api/videos/VIDEO_ID/comments HTTP/1.1
Host: gdata.youtube.com
Content-Type: application/atom+xml
Content-Length: CONTENT_LENGTH
Authorization: Bearer ACCESS_TOKEN
GData-Version: 2
X-GData-Key: key=DEVELOPER_KEY
<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="http://www.w3.org/2005/Atom"
xmlns:yt="http://gdata.youtube.com/schemas/2007">
<content>This is a crazy video.</content>
</entry>
我搜到一些教程都是用 curl 的。我没有 curl,只能用 file_get_contents() 来做。我不太清楚怎么写 header,代码也不成功。