searching for tweets from multiple users with api 1.1 - ios

Ever since I upgraded to api 1.1, I am unable to search for tweets from multiple users. For example this search-https://api.twitter.com/1.1/search/tweets.json?q=from:commute_by_bike OR from:BikeLeague OR from:peopleforbikes OR from:bikesbelong &count=20 returns zero tweets. This worked previously with the 1.0 api. If I search for just one of these users, I get the corrects results so I know the authentication is working. Any suggestions? thanks.

I've tested the query you post above and using the following curl command (which I got from Twitter's OAuth tool), and I get several tweet results back. Your actual query does work, there is probably just a problem with the formatting somewhere. Retry your query using the OAuth tool to troubleshoot out any formatting problems, then edit your query.
curl --get 'https://api.twitter.com/1.1/search/tweets.json' \
--data 'count=20&q=from%3Acommute_by_bike+OR+from%3ABikeLeague+OR+from%3Apeopleforbikes+OR+from%3Abikesbelong+' \
--header 'Authorization: OAuth oauth_consumer_key="XXXXXXXX", oauth_nonce="XXXXXXXX", oauth_signature="XXXXXXXX", oauth_signature_method="XXXXXXX", oauth_timestamp="XXXXXXXXX", oauth_token="XXXXXXXX", oauth_version="1.0"' --verbose

With the new 1.1 api, I'm searching for a hashtag with the following line of code:
[NSString stringWithFormat:#"https://api.twitter.com/1.1/search/tweets.json?q=%%23%#&result_type=mixed", hashtag]
Where hashtag is an NSString, not containing the #. You need authentication for that, but you mentioned that the authentication works. Good luck!

Related

Want to write api of twitter to post tweet without any gem/library means with curl command

I am new to ruby want to create an api which post tweet to twitter without help of any gem include as we did on command line by running below code:
curl --request 'POST' 'https://api.twitter.com/1.1/statuses/update.json' --data 'status=Maybe+he%27ll+finally+find+his+keys.+%23peterfalk' --header 'Authorization: OAuth oauth_consumer_key="i6baQCTt1sCXAo8YWcKhuly9Z", oauth_nonce="12f94f3e4b2ded3bbfdfe781de60ae73", oauth_signature="x6%2Fi2w%2F0RjN4prcFmA5HthOZU3Q%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1461568353", oauth_token="2291131736-LpQkfe5diMTung5mVQ0Dc5EKA9u8qnIgWuPqau9", oauth_version="1.0"' --verbose
But in controller how can we use this command so it get ouath_signature and post the tweet.
As In php it did with curl want same way ion ruby.
Please help me to get out of it
You may use rest-client to make your api calls.
Or if you really don't even want to use that gem also.
Try this : http://ruby-doc.org/stdlib-2.3.0/libdoc/net/http/rdoc/Net/HTTP.html
which comes with the ruby standard library
If I understand correctly, you can use:
http://ruby-doc.org/stdlib-2.3.0/libdoc/net/http/rdoc/Net/HTTP.html

API Authentication with Devise

I am basically trying to implement a User authentication system that POSTs information to an API/Web Service to cross-reference credentials, therefore rejecting them or allowing them to login.
I am not sure if I understand how this whole system works exactly, but I have been researching a lot on Authentication using Devise and APIs, and do not understand how none of the examples refer to the actual URI of the API at all.
For example, when I first began this process, I made sure to be able to connect to the web service through cURL:
curl -H "Content-Type: application/json" -d '{"RuntimeEnvironment":1,"Email":"someone#example.com","Password":"Pa$$worD"}' -X POST http://blahblah/WebService/AuthenticateLogin
However in every single blog post / tutorial / guide / StackOverflow question I have been on, literally none of them specifically refer to the http://blahblah/WebService/AuthenticateLogin as I did in my cURL request.
Am I searching for the wrong thing?
Or is it actually there and I'm just not understanding?
Also how do tokens factor into this scenario?
The web service I am using does not require/return a token.

How to get the stream key for twitch.tv

I write an app for broadcasting to twitch.tv using C++. For that streaming I need to know the user stream key, usually an user gets that key from the page,
http://www.twitch.tv/user_name/dashboard/streamkey
But I would like get it via my app by using the user name/password.
Any ideas?
You will get it here (change "yourtwitch" by your twitch nickname")
http://www.twitch.tv/yourtwitch/dashboard/streamkey
The link simply moved. You can get this link on the main page of twitch.tv, click on your name then "Dashboard".
This may be an old thread but I came across it and figured that I would give a final answer.
The twitch api is json based and to recieve your stream key you need to authorize your app for use with the api. You do so under the connections tab within your profile on twitch.tv itself.. Down the bottom of said tab there is "register your app" or something similar. Register it and you'll get a client-id header for your get requests.
Now you need to attach your Oauthv2 key to your headers or as a param during the query to the following get request.
curl -H 'Accept: application/vnd.twitchtv.v3+json' -H 'Authorization: OAuth ' \
-X GET https://api.twitch.tv/kraken/channel
documentataion here
As you can see in the documentation above, if you've done these two things, your stream key will be made available to you.
As I said - Sorry for the bump but some people do find it hard to read the twitch* api.
Hope that helps somebody in the future.
You may obtain the stream key via the API:
https://github.com/justintv/twitch-api
As of January 2018 the url is https://www.twitch.tv/username/dashboard/settings/streamkey

How do I execute this command (curl) in rails? That is, what library contains a tool that allows me to pass an API key this way?

Here's the command I need to execute: (using the example API key)
curl -v -u 1971800d4d82861d8f2c1651fea4d212:api_token \
-X GET https://www.toggl.com/api/v8/workspaces/777/tasks
I am writing a dashing/sinatra based dashboard that shows a summary of the information from our Toggl account. My question is, how to I open this url in sinatra using something like
open('http://...) do |f|
A successful curl returns an array (json) that I can parse for the info I need.
I'm not entirely sure how to tackle this. I have some ideas but they aren't well formed enough to properly comment on them. I though I'd bounce this off of you all for inspiration and information.
I'm all ears.
Check out HTTParty. The example in the README shows basically exactly what you're looking to do using auth headers:
https://github.com/jnunemaker/httparty

curl post testing oauth 2.0 not working while the http example does

I am trying to understand how Google authentication works with OAuth 2.0. They give some examples at this link.
I am having trouble with one of the first steps. I can execute this http request in a browser:
https://accounts.google.com/o/oauth2/auth?scope=https://www.google.com/m8/feeds&client_id=21302922996.apps.googleusercontent.com&redirect_uri=https://www.example.com/back&response_type=token
and that works fine.
When I try to convert it to a curl GET operation,
curl https://accounts.google.com/o/oauth2/auth?scope=https://www.google.com/m8/feeds&client_id=21302922996.apps.googleusercontent.com&redirect_uri=https://www.example.com/back&response_type=token
I get a response that tells me there is an OAuth 2.0 error: invalid_request.
Converting it to a POST, I can't get this operation to work.
curl http://accounts.google.com/o/oauth2/auth -d “scope=https://www.google.com/m8/feeds&client_id=21302922996.apps.googleusercontent.com&redirect_uri=https://www.example.com/back&response_type=token”
The response is that the document has moved.
If I try this, I get similar results.
curl http://accounts.google.com/o/oauth2/auth -data-urlencode “scope=https://www.google.com/m8/feeds&client_id=21302922996.apps.googleusercontent.com&redirect_uri=https://www.example.com/back&response_type=token”
I have never used curl or OAuth in my code before, so I want to understand some of these basics. Can someone tell me what is wrong with my GET and POST ?
I don't have a sure answer for you, but I was working on something similar for Instagram and one thing that stumped me for a while was that my redirect URL looked to be the same as Instagram expected, but I kept getting errors.
Like you, when I 'hand coded' the redirect URL, I got the result I expected, but my automated calls to the authentication URL failed. It turned out my ampersands were a url encoded which Instagram compared to the redirect URL and saw they were not identical. I'm not sure if that will get you closer to an answer, but I thought I'd share my experience since your question reminds me of the situation I was in. Good luck.

Resources