How to run example from developer.twitter.com

40 Views Asked by At

I've just seen snippet of code on developer.twitter.com

  'curl --request POST \
  --url https://api.twitter.com/1.1/tweets/search/30day/<ENV>.json \
  --header 'authorization: Bearer <BEARER_TOKEN>' \
  --header 'content-type: application/json' \
  --data '{
                "query":"from:TwitterDev lang:en",
                "maxResults": "100",
                "fromDate":"<YYYYMMDDHHmm>", 
                "toDate":"<YYYYMMDDHHmm>"
                }'

page of api

Using cmd command line or Windows power shell i receive error because of multiline format of the code. However everything is ok for string without line breaks.

My question is - Where i can run this snippet of code without errors?

1

There are 1 best solutions below

2
Andy Piper On

This command works in bash and zsh on Linux and Mac - I have not been able to test it on Windows. In PowerShell, the multi-line continuation character is backtick `. Remember to replace the <ENV> and <BEARER_TOKEN> values and to edit or remove the fromDate and toDate parameters. Also, the leading single quote is not from the documentation page, so you'll need to remove that as well.