关于 Curl 方法的 Google OpenSocial API 问题

发布于 2024-11-15 05:28:15 字数 1820 浏览 6 评论 0原文

我正在尝试使用 Google Opensocial API 构建一个应用程序。 但是,当我使用以下 CURL 标头发出 POST 请求时,我收到 405 Method not allowed 错误:

CURLOPT_URL : http://www.orkut.com/social/rpc/
CURLOPT_POSTFIELDS : [{"method":"people.get","id":"self","params":{"userId":["@me"],"groupId":"@self","fields":["displayName","currentLocation","thumbnailUrl","gender","name"]}},{"method":"people.get","id":"friends","params":{"userId":["@me"],"groupId":"@friends","fields":["displayName","currentLocation","thumbnailUrl","gender","name"],"count":300}}]
CURLOPT_CUSTOMREQUEST : POST
CURLOPT_RETURNTRANSFER : true
CURLOPT_USERAGENT : osapi 1.0
CURLOPT_FOLLOWLOCATION : 1
CURLOPT_SSL_VERIFYPEER : false
CURLOPT_HEADER : true
CURLINFO_HEADER_OUT : true
CURLOPT_HTTPHEADER : Array
        (
            [0] => Authorization: OAuth oauth_body_hash="A3ZOHT4b3YMOzEfg+2j3v+N302E=", oauth_nonce="6ad533sdfsb9261ssdfsdf29af7d", oauth_version="1.0", oauth_timestamp="1318236734", oauth_consumer_key="www.mydomain.com", oauth_token="1%2FKhAasdfsd8YX2bfsdfsdf6MsdfsfsdfsdfJYyULWUog", oauth_signature_method="HMAC-SHA1", oauth_signature="osdf4pShOsdfsdf88nnpwsdfsdf9g%3D"
            [1] => Content-Type: application/json
            [2] => Content-Length: 0
            [3] => User-Agent: osapi 1.0
        )

以下是我收到的 CURL-POST 响应:

["http_code"] =>  int(405)
["data"] => string(12614) 
    "HTTP/1.1 405 Method Not Allowed
    Content-Type: text/html; charset=UTF-8
    Content-Length: 12462
    Date: Tue, 14 Jun 2011 08:07:58 GMT
    Server: GFE/2.0

我在 Google Codes 论坛上询问了此问题,他们告诉我从以下位置删除以下行: CURL 请求,因为我的网站托管在 hostgator 上。

CURLOPT_CUSTOMREQUEST : POST

我尝试了上述操作,但仍然收到 405 Method not allowed 错误。请在这个问题上进一步帮助我。 我是否需要修改上面的 PHP-CURL 代码才能发送 POST 请求?如果是这样,那么请帮助我..

I am trying to build an application using Google Opensocial API.
But when i make a POST request with following CURL headers, i am getting 405 Method not allowed error :

CURLOPT_URL : http://www.orkut.com/social/rpc/
CURLOPT_POSTFIELDS : [{"method":"people.get","id":"self","params":{"userId":["@me"],"groupId":"@self","fields":["displayName","currentLocation","thumbnailUrl","gender","name"]}},{"method":"people.get","id":"friends","params":{"userId":["@me"],"groupId":"@friends","fields":["displayName","currentLocation","thumbnailUrl","gender","name"],"count":300}}]
CURLOPT_CUSTOMREQUEST : POST
CURLOPT_RETURNTRANSFER : true
CURLOPT_USERAGENT : osapi 1.0
CURLOPT_FOLLOWLOCATION : 1
CURLOPT_SSL_VERIFYPEER : false
CURLOPT_HEADER : true
CURLINFO_HEADER_OUT : true
CURLOPT_HTTPHEADER : Array
        (
            [0] => Authorization: OAuth oauth_body_hash="A3ZOHT4b3YMOzEfg+2j3v+N302E=", oauth_nonce="6ad533sdfsb9261ssdfsdf29af7d", oauth_version="1.0", oauth_timestamp="1318236734", oauth_consumer_key="www.mydomain.com", oauth_token="1%2FKhAasdfsd8YX2bfsdfsdf6MsdfsfsdfsdfJYyULWUog", oauth_signature_method="HMAC-SHA1", oauth_signature="osdf4pShOsdfsdf88nnpwsdfsdf9g%3D"
            [1] => Content-Type: application/json
            [2] => Content-Length: 0
            [3] => User-Agent: osapi 1.0
        )

Following is the CURL-POST response I am recieving :

["http_code"] =>  int(405)
["data"] => string(12614) 
    "HTTP/1.1 405 Method Not Allowed
    Content-Type: text/html; charset=UTF-8
    Content-Length: 12462
    Date: Tue, 14 Jun 2011 08:07:58 GMT
    Server: GFE/2.0

I asked about this issue on Google Codes forum and they told me to remove following line from CURL request as my website is hosted on hostgator.

CURLOPT_CUSTOMREQUEST : POST

I tried above thing but still i am getting 405 Method not allowed error. Kindly assist me further on this issue.
Do i need to modify my PHP-CURL code above to send POST request? If so, then please help me..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

纸伞微斜 2024-11-22 05:28:15

Google 社交规范提供了一个示例其中 people.get 是通过 GET 请求的,而不是通过 POST 请求的。通常请记住,GET 用于请求信息,而 POST 用于更改现有信息。

The Google Social specification has an example in which people.get is requested with GET, not via POST. Generally keep in mind that GET is for requesting information, while POST is for changing existing information.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文