pablobarbera / instar Goto Github PK
View Code? Open in Web Editor NEWDev version of instaR package: Access to Instagram API via R
Dev version of instaR package: Access to Instagram API via R
i've been trying to use instaR, but failed at getting an access token - getting the response:
Authentication complete.
Error in init_oauth2.0(self$endpoint, self$app, scope = self$params$scope, :
Bad Request (HTTP 400). Failed to get an access token.
when examining the request using with_verbose(), i don't see any additional info.
httr::with_verbose(my_oauth <- instaOAuth(app_id=client_id, app_secret=client_secret))
Waiting for authentication in browser...
Press Esc/Ctrl + C to abort
Authentication complete.
POST /oauth/access_token HTTP/1.1
Host: api.instagram.com
User-Agent: libcurl/7.43.0 r-curl/2.2 httr/1.2.1
Accept-Encoding: gzip, deflate
Cookie: csrftoken=oLgx7eQh8uZH1ZWMl53lC2y0JJWQkmwd
Accept: application/json, text/xml, application/xml, /
Content-Type: application/x-www-form-urlencoded
Content-Length: 206client_id=CLIENT_ID&redirect_uri=http%3A%2F%2Flocalhost%3A141>0%2F%2F&grant_type=authorization_code&code=98e38f8c53354a22bd3786f96cd19e3e&client_secret=CLIENT_SECRET
<- HTTP/1.1 400 Bad Request
<- Cache-Control: private, no-cache, no-store, must-revalidate
<- Vary: Cookie, Accept-Language
<- Content-Language: en
<- Date: Mon, 21 Nov 2016 00:27:48 GMT
<- Content-Type: application/json
<- Pragma: no-cache
<- Expires: Sat, 01 Jan 2000 00:00:00 GMT
<- Set-Cookie: csrftoken=oLgx7eQh8uZH1ZWMl53lC2y0JJWQkmwd; expires=Mon, 20-Nov->2017 00:27:48 GMT; Max-Age=31449600; Path=/; Secure
<- Connection: keep-alive
<- Content-Length: 114
<-
Error in init_oauth2.0(self$endpoint, self$app, scope = self$params$scope, :
Bad Request (HTTP 400). Failed to get an access token.
i saw people reporting similar issues with R FB libraries, some of them reported that reverting to an older httr version resolved the issue (due to the current version possibly having some issues with http instead of https requests).
R version 3.2.3 (2015-12-10)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.1 (El Capitan)locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8attached base packages:
[1] stats graphics grDevices utils datasets methods baseother attached packages:
[1] instaR_0.2.4 jsonlite_1.1 httr_1.2.1loaded via a namespace (and not attached):
[1] R6_2.1.2 tools_3.2.3 withr_1.0.1 curl_2.2 memoise_1.0.0 Rcpp_0.12.4 >git2r_0.14.0 digest_0.6.9 httpuv_1.3.3
[10] devtools_1.11.1
Hi Pablo,
Thank you for your great package. I wouldlike to install your package by using following R commands but it couldn't be installed.
devtools::install_github("pablobarbera/instaR")
I am getting a "Error. User name not found." error when calling getUserMedia. I am running R 3.02 for Mac. It looks like the underlying error is generated because the function callAPI is not defined. Perhaps it is part of another package?
search()
[1] ".GlobalEnv" "package:Rfacebook" "package:RCurl" "package:bitops"
[5] "package:httpuv" "package:instaR" "package:rjson" "package:httr"
[9] "tools:RGUI" "package:stats" "package:graphics" "package:grDevices"
[13] "package:utils" "package:datasets" "package:methods" "Autoloads"
[17] "package:base"
Thanks for any help you can provide!
Matt
It's more modern, more robust and better maintained.
getFollows(..., verbose = F)
and getFollowers(..., verbose = F)
don't suppress the output if there is a pagination present
I keep getting subscript out of bounds error whenever I try to get comments.
Should return list of users who liked and commented on a specific post
Hi,
Thanks for making this package available.
How to create and access realtime subscriptions? (refs here: https://instagram.com/developer/realtime/)
The procedure looks similar to the OAuth method but requires to return the hub.challenge parameter.
Any idea on how to handle this authorisation process in R?
Thanks!
First, thx for all your work Pablo.
When i try to auth i get the following error message. It seems like it is the same problem as with Rfacebook and latest httr ( http://stackoverflow.com/questions/31362523/rfacebook-authentication-error ).
my_oauth <- instaOAuth(app_id="XXXX", app_secret="XXXXX")
Copy and paste into 'OAuth redirect_uri' on Instagram App Settings: http://localhost:1410
When done, press any key to continue...
Error: Deprecated: supply token object to config directly
Figure out where the search query is applied to (just caption or also comments?)
Hello Pablo!
Can you check if the authentication is working correctly? It seems that they have changed something related to it and that is affecting the package.
Thanks!
I am trying to get the media for the account "bergdorfs" by running this command
berg <- getUserMedia(username = "bergdorfs", token, n=5327)
It gets 2010 posts but after that I get the following error
Error in vect[notnulls] <- unlist(lapply(lst, "[[", field)) :
replacement has length zero
Hi
I am pretty new to this hence the opening and closing! I did not want to submit it when I did!
Basically the new permissions of Instagram mean you can only get the last 20 posts while in "Sandbox" mode before you make your app live.
Any idea how easy it is to submit your app for review or if there is another workaround.
My code and output as so:
CopperPics <- getUserMedia(username = "coppercar_thesausage", token = my_oauth, n = 48, folder = 'data')
20 posts
Downloading pictures...
Whereas there are actually 48 posts in that account...
When I run the following command it starts to return values but then errors out
Comments <- searchInstagram(tag="MySearchTerm",token = my_oauth, n=500)
20 posts 40 60 80 100 120 140 160 180 198
Error in curl::curl_fetch_memory(url, handle = handle) :
Couldn't resolve host name
If I change n=100 the command returns a dataframe successfully but if you search directly on instragram you can see that n could be larger (with my search query over 300 items were tagged)
Running n =198 works but n=199 returns the error message above
Hello,
I have installed and reinstalled the instaR and httr packages several times now but R cannot find the function instaOAuth. Am I the only one having trouble with this?
Thanks for any help,
Em
i'm trying to run InstaR package with R Studio. After install all neccessary package and have a token, i try to run
> **instaf <- getFollows("zadwhitecloud", token)
**
but it raise this error "Error in content$data[[1]]$id : $ operator is invalid for atomic vectors"
Any one can help me, pls? how to fix this?
I am attempting a test of the searchInstagram function after getting authentication from instagram
rctid <- searchInstagram(tag = "rctid", token = my_oauth, n = 100)
This is a tag for the Portland Timbers MLS team and I searched on their opening game day. I'm returning the following error:
Error in searchInstagram(tag = "rctid", token = my_oauth, n = 100) :
0 posts found.
Interestingly other functions did work like the getTagCount function returned 73693
testtag <- getTagCount(tag="rctid", token = my_oauth)
What am I doing wrong here?
The javascript code in the beginning of the file needs an update as it is showing up incorrectly in Github.
In R world, a package basically corresponds to an app, so you should include a default app id and secret with the package to avoid some of the initial setup hassle.
Hi! When I run your example for getting media with a given hashtag:
obama <- searchInstagram(tag="obama", token=my_oauth)
I get an error message saying: Error in searchInstagram(tag = "obama", token = my_oauth) :
0 posts found.
Many thanks for help with this issue :)
Hi,
I'm trying to get started using this package, but I keep getting the following error when trying to authenticate and authorize my app via the instaOAuth
function:
{"code": 400, "error_type": "OAuthException", "error_message": "Redirect URI does not match registered redirect URI"}
Any ideas on how to address this?
Thanks!
I'm getting the above error when using the following code, which I took directly from your example.
pm <- getUserMedia("portlandmeadows", token, n=100, folder="pm_pics")
All of my authorizations have been included and verified through Instagram.
Should interact with /media/popular API endpoint
Hi Pablo. I have the next problem:
I type this:
vocho <- searchInstagram(tag="volkswagenmexico", token=mytoken)
and I have
Error in instaR::getUser(username = "volkswagenmexico", token = my_oauth) :
Error. User name not found.
I check the code with debug and the problem is callAPI. I appreciate so much your help.
Thanks
Does this have any affect on instaR or can one still register for an App and use the package?
how to fix an error like this
library(twitteR)
library(ROAuth)
customer_key<-"-aaaaaa"
customer_secret<-"aaaaaaaa"
access_token<-"212123213-aaaaa"
access_secret<-"ccccccccccccc"
setup_twitter_oauth(customer_key,customer_secret,access_token,access_secret)
Tweets = searchTwitter("anxiety", n=100, lang = "en")
Error: invalid assignment for reference class field ‘language’, should be from class “character” or a subclass (was class “NULL”)
I User RStudio for run this source code, this is my first time using the twitter API. before I saw the tutorial and they succeeded, after I tried it and there was an error like that. thankyou
After registering a client in Instagram and having back my Client ID and Client Secret I got this error.
{"error_type": "OAuthException", "code": 400, "error_message": "Redirect URI does not match registered redirect URI"}
The script used is this (app_id and app_secret are fictitious)
install.packages("instaR")
library(instaR)
my_oauth <- instaOAuth(app_id="xxxxxxxx", app_secret="yyyyyyyy")
save(my_oauth, file="my_oauth")
alessandrozonin <- getUserMedia( username="alessandrozonin", token=my_oauth )
comments <- getComments( alessandrozonin$id[1], token=my_oauth )
thank you for your time
I'm trying to test the functionality of instaR inside the Sandbox and received the following error when trying to run most commands:
For example, Running getFollowers on one of my Sandbox users returns:
Error in content$data[[1]]$id : $ operator is invalid for atomic vectors
Running searchInstagram(tag="fall",token, n=10, folder="test") returns:
32 posts
Error in x[[field]] : subscript out of bounds
Is this a result of the Sandbox or is this a result of something else?
Thank you.
John
While the instaOauth recommends http://localhost:1410 I appear to need http://localhost:1410/ as the redirect_uri value to be used on my client config on https://instagram.com/developer/clients/manage/
I'm trying to use the InstaR, but I'm having errors.
When I use the getUser(), I receive the error:
teste <- getUser(user = "diegogaona", token = insta_token)
Error in get_oauth_sig() : OAuth has not been registered for this session
When I try getFollowers()
teste <- getFollowers(username = "diegogaona", token = insta_token)
Error in getFollowers(username = "diegogaona", token = insta_token) :
Error. User name not found.
I follow the instructions to create the oauth(), the process is ok, (i'm in sandbox mode), but I don't understand why the errors occur.
<Token>
<oauth_endpoint>
authorize: https://api.instagram.com/oauth/authorize
access: https://api.instagram.com/oauth/access_token
<oauth_app> instagram
key: XXXXXXXXXXXXXXXXXXXXXXXX
secret: <hidden>
<credentials> access_token, user
---
Thes errors occur only for me?
I'm getting the error above when I attempt to run getFollowers (or any other instaR function).
My sessioninfo(), in case relevant:
R version 3.3.1 (2016-06-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] instaR_0.2.4 jsonlite_1.1 httr_1.2.1
loaded via a namespace (and not attached):
[1] R6_2.1.3 tools_3.3.1 curl_1.2 Rcpp_0.12.7 httpuv_1.3.3
Thanks!
Cam
Hello Pablo.
I love this library but I have been struggling with bigger than 20 posts batch scrap. I checked the getUserMedia function you wrote and definitely there is something about paginations if there are more than 20.. which is Instagrams's limit. But when I use the n=100 it only brings the most recent 20 and stops. Is it possible to get a fix on this?
Here is the documentation on paginations: https://instagram.com/developer/endpoints/
Thanks again for your amazing work.
I followed the tutorial from https://github.com/pablobarbera/instaR/blob/master/examples.R
and ran the code:
app_id <- "AAAAAA"
app_secret <- "YYYYYXXXXYYY"
token <- instaOAuth(app_id, app_secret)
I receive this in the console:
Waiting for authentication in browser...
Press Esc/Ctrl + C to abort
Authentication complete.
Error in oauth2.0_access_token(endpoint, app, code = code, user_params = user_params, :
Bad Request (HTTP 400). Failed to get an access token.
I already put http://localhost:1410/ as a valid redirect URI in instagram.
This is my sessionInfo
R version 3.4.3 (2017-11-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=English_Australia.1252
[2] LC_CTYPE=English_Australia.1252
[3] LC_MONETARY=English_Australia.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_Australia.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods
[7] base
other attached packages:
[1] instaR_0.2.4 jsonlite_1.5 httr_1.3.1
loaded via a namespace (and not attached):
[1] compiler_3.4.3 R6_2.2.2 tools_3.4.3 curl_3.1
[5] yaml_2.1.16 Rcpp_0.12.15 httpuv_1.3.5
I am trying to get comments on the particular Instagram user but, as per the permission policy, I could retrieve the data.
so could you guide me what should I do to get the permission access and get the Comments and like of users?
Also, what are the process to get all data from any particular user?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.