using cURL with Twitter API is giving me an error

I setup a twitter development account, and already have created an small app with it. Today I was trying to use cURL with Twitters oAuth signing results page (which generates the cURL command for you).

I'm trying to run the following GET > https://api.twitter.com/1.1/statuses/home_timeline.json

when I paste that into Twitter to convert it to the cURL command I get >

curl --get 'https://api.twitter.com/1.1/statuses/home_timeline.json' --header 'Authorization: OAuth oauth_consumer_key="CONSUMER_KEY", oauth_nonce="OAUTH_NONCE_KEY", oauth_signature="OAUTH_SIG_KEY", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1379360432", oauth_token="OAUTH_TOKEN", oauth_version="1.0"' --verbose

When I try to run cURL on Windows 7 with the command I get the following error >

* Protocol 'https not supported or disabled in libcurl * Closing connection -1 curl: (1) Protocol 'https not supported or disabled in libcurl * Rebuilt URL to: OAuth/ * Adding handle: conn: 0x1dbd530 * Adding handle: send: 0 * Adding handle: recv: 0 * Curl_addHandleToPipeline: length: 1 * - Conn 0 (0x1dbd530) send_pipe: 1, recv_pipe: 0

followed by more errors.. what am I doing wrong?

I can successfully run the following > curl https://twitter.com/‎

and I see the results for the above command. Why wouldn't the twitter --get work? Am I running it correctly?

EDIT When I remove the quotes and run it as follows >

curl --get https://api.twitter.com/1.1/statuses/home_timeline.json --header Authorization: OAuth oauth_consumer_key="KEY1", oauth_nonce="KEY2", oauth_signature="KEY3", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1379364692", oauth_token="KEY4", oauth_version="1.0" --verbose

I get further.. but I get a different error >

SSL certificate verify ok.
GET /1.1/statuses/home_timeline.json HTTP/1.1
User-Agent: curl/7.32.0
Host: api.twitter.com
Accept: */*

HTTP/1.1 400 Bad Request
content-length: 61
content-type: application/json; charset=utf-8
date: Mon, 16 Sep 2013 20:54:55 UTC
Server tfe is not blacklisted
server: tfe
set-cookie: guest_id=v1%3A137936489538017864; Domain=.twitter.com; Path=/; Exp
ires=Wed, 16-Sep-2015 20:54:55 UTC
strict-transport-security: max-age=631138519

{"errors":[{"message":"Bad Authentication data","code":215}]}* Connection #0 to
host api.twitter.com left intact
Rebuilt URL to: OAuth/

Any ideas?


I figured out the answer to my own question. When you use the oAuth tool on the twitter development site, you can get a cURL command to test an API function out.

The oAuth twitter tool generated code works in Linux but if you're running a Windows machine you need to convert all the ' (apostrophe) to " (quotes). I replaced my secure tokens/keys with a generic "KEY" variable below to demonstrate.

ex) // runs in Windows

curl --get "https://userstream.twitter.com/1.1/user.json" --header 
"Authorization: OAuth oauth_consumer_key="KEY", oauth_nonce="KEY",
oauth_signature="KEY", oauth_signature_method="HMAC-SHA1", 
oauth_timestamp="1379378318", oauth_token="KEY", oauth_version="1.0"" 
--verbose
链接地址: http://www.djcxy.com/p/66192.html

上一篇: RoR Twitter API oAuth:“无法验证你的身份。”

下一篇: 使用cURL与Twitter API给我一个错误