Perusing the Instagram API I see it's pretty straightforward to search for photos by tag OR by username. However, I can't seem to find anything on searching by both. Is it possible to query the API and get only results of a specific tag from a specific user?
-
Any leads on this? Trying to do the same...– couzziAug 29, 2013 at 17:07
-
Nope. As far as I know it's not really possible unless you just grab a whole bunch of posts from a specific user then parse them for the tag. That isn't a very elegant solution though.– LoneWolfPRSep 10, 2013 at 15:37
4 Answers
Your best bet is to do a lookup on a user and then sift through the results and get each picture with a certain tag
There is an opportunity how to do it:
https://api.instagram.com/v1/tags/SEARCH_TAG/media/recent?client_id=CLIENT_ID&callback=MY_CALLBACK
SEARCH_TAG
- input
CLIENT_ID
- its your ID
after registration
MY_CALLBACK
- your callback function.
You will receive your response in Form of JSONP
.
After it you can search your response with the parameters your want.
-
Good point, but since would return all Instagram with certain tag, that means one would have to sift through too many data results to find desired user. Looks like it's best that can be done with Instagram API limitation, and it isn't much.– RudiJun 5, 2013 at 20:30
You could make a list of images with a certain tag and then a list of images with a certain username. You could then compare the two lists. I'd recommend python with Beautiful Soup.
Wrote the code for you in php:
$api = file_get_contents("https://api.instagram.com/v1/tags/YOURTAG/media/recent?access_token=YOURACCESSTOKEN");
$json = json_decode($api,true);
foreach($json['data'] as $data){
if($data['user']['username']=="YOURSPECIFICUSERNAME"){
//action
}
}
Enjoy : )
-
-
-
after logging in, go into the api link, i.e. instagram.com/developer/endpoints/relationships you'll see api.instagram.com/v1/users/3/follows?access_token=xxxxxxxx where xxxxxxxx is your access token– GeorgeFeb 21, 2014 at 7:50
-
I'm using this foreach approach to unset posts which !== to the username. It's removing most of the posts but leaving some in. Has anyone else had any problems like this? Sep 10, 2014 at 7:31