Cannot find funtion instaOAuth
Opened this issue · 4 comments
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
library(instaR)
library(httr)
Try to run Above library if it doesn't work then
app_name <- "app_name"
client_id <- "API ID"
client_secret <- "Client Secret key"
scope = "public_content"
#assign authorize and access
instagram <- oauth_endpoint(
authorize = "https://api.instagram.com/oauth/authorize",
access = "https://api.instagram.com/oauth/access_token")
myapp <- oauth_app(app_name, client_id, client_secret)
hello iamrajeshchauhan,
thank you for providing us the codes and it was successful for me.
as im totally new to R programming,
can you please let me know how to get data by coding?
After using your codes and i tried this:
my_oauth <- instaOAuth(app_id="XXX", app_secret="XXX")
save(my_oauth, file="my_oauth")
load("my_oauth")
obama <- getUserMedia( username="barackobama", token=my_oauth )
comments <- getComments( obama$id[1], token=my_oauth )
but it wasn't working so well and it said:
load("my_oauth")
Error in readChar(con, 5L, useBytes = TRUE) : cannot open the connection
In addition: Warning message:
In readChar(con, 5L, useBytes = TRUE) :
cannot open compressed file 'my_oauth', probable reason 'No such file or directory'
obama <- getUserMedia( username="ASOS", token=my_oauth )
Error in getUserMedia(username = "ASOS", token = my_oauth) :
Error. User name not found. Does this application have permission to access public content?
comments <- getComments( obama$id[1], token=my_oauth )
Error in paste0("https://api.instagram.com/v1/media/", id, "/comments") :
object 'obama' not found
Can you please let me know what happened in my code?
And how can I get those comments?
Thank you so much!
I also encountered the same problem.
you will find additional info on page 10
https://cran.r-project.org/web/packages/instaR/instaR.pdf
the website https://www.instagram.com/oauth displayed error until i installed "httpuv" using:
install.packages("httpuv")
then i was prompted a website where i could give permission to my app.
R stated "Authentication complete." afterwards.website stated: "Authentication complete. Please close this page and return to R."
R also stated "in curl::curl_fetch_memory(url, handle = handle) :
Failed to connect to api.instagram.com port 443: Connection refused"
I guess the instaOAuth does not grab the code corretly, maybe a versioning issue.
The URL looks like:
http://localhost:1410/?code=dd68af56f6a74932xx6e31f2f6cb1773&state=052hGY6YkI
With respect to all permissions in the API settings, there is N/A, is it because of that?!
When i try to manually run:
foo <- getUserMedia( username="foo", token="dc8aed592dc1442c9437c18bc596e4a9" )
using an afore-generated token it will result in:
Error in callAPI(url, token) :
Error in access token. See help for details.
Okay, i think i fixed the token generation and all, but the problem remains that public content is not accessible.
For example:
tsq <- searchInstagram(lat=40.7577, lng=-73.9857, distance=500, token=token, n=500, folder="timessquare")
will result in:
Error in searchInstagram(lat = 40.7577, lng = -73.9857, distance = 500, :
0 posts found. Does this application have permission to access public content? See ?searchInstagram for more information
it does not depend on what the details within the token generation are, like scope etc. The token itself seems not to be valid for this.
https://www.instagram.com/developer/authorization/
"basic" scope things should work, i.e.:
obama_info <- getUser("instagram", token=my_oauth)
should work. instead it yields:
Error. User name not found. Does this application have permission to access public content?
really sad overall :(
http://thepoliticsofsystems.net/2016/05/closing-apis-and-the-public-scrutiny-of-very-large-online-platforms/