GitHub访问令牌POST错误(需要Cookies)

时间:2013-03-03 12:34:10

标签: php cookies oauth-2.0 access-token github-api

我有一个PHP应用程序,我正在尝试与GitHub集成。从身份验证中获取代码后,我尝试用access_token交换它,我收到以下错误

Cookies must be enabled to use GitHub.

我正在使用cURL库来执行我的请求。我设置的标题是

  • 内容长度:{length}
  • 接受:application / json
  • User-Agent:my-app

可以帮我解决这个问题吗?

1 个答案:

答案 0 :(得分:1)

使用

/* cURL will start a new cookie session and ignore any previous cookies */
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
/* this is the name of the file where cURL should save cookie information */
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); 
// could be empty, but cause problems on some hosts