Coder Social home page Coder Social logo

jinstagram's Introduction

Note: jInstagram will no longer be supporting the new Instagram Graph API. Please use RestFB library to interact with the new Graph API (https://restfb.com/)

jInstagram Build Status Maven Central javaDoc Coverage Status Coverity Scan Build Status Join the chat at https://gitter.im/sachin-handiekar/jInstagram

A java library for the Instagram API.

An unofficial Java library for the Instagram API.

Note : jInstagram uses code from the scribe-java library developed by Pablo Fernandez.

  • Maven Integration

If you're using Maven in your project, then you can integrate jInstagram by adding the following dependency in your pom.xml

<dependency>
   <groupId>com.sachinhandiekar</groupId>
   <artifactId>jInstagram</artifactId>
   <version>1.2.2</version>
</dependency>

If you prefer using the latest snapshot build, include the following lines to your pom.xml.

    <repositories>
        <repository>
            <id>oss.snapshots</id>
            <name>OSS Sonatype Snapshot Repository</name>
            <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>com.sachinhandiekar</groupId>
            <artifactId>jInstagram</artifactId>
             <version>1.2.3-SNAPSHOT</version>
        </dependency>
    </dependencies>

You can also integrate jInstagram by adding the following jar files in your project -

Please see the API Usage for more details.

Please see the Realtime API Usage for more details.

Please see the sample project to see a working example of jInstagram integration.

Please see the development guide.

Please see the wiki link for a list of projects using jInstagram.

Please check the license file.

jinstagram's People

Contributors

abargnesi avatar aboothew2o avatar arinto avatar brenn-omnigon avatar bryant1410 avatar dariusj18 avatar didikeke avatar fkorotkov avatar geoff-keyes avatar georgekankava avatar jackjamieson avatar jcodagnone avatar jerryrt avatar lgfischer avatar mallorcasoftware avatar marz619 avatar nucleoid avatar piccirello avatar rahst12 avatar robsoncassol avatar robsongauge avatar sachin-handiekar avatar santinomazzocchi avatar sigpwned avatar snicoll avatar stevenschlansker avatar timkoers avatar valery1707 avatar yoshida-mediba avatar yousefed avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jinstagram's Issues

Params not being passed by getRecentMediaTags(String, int, int)

java.instagram

/**
     * Get a list of recently tagged media.
     *
     * @param tagName name of the tag.
     * @return a TagMediaFeed object.
     * @throws InstagramException if any error occurs.
     */
    public TagMediaFeed getRecentMediaTags(String tagName, int minId, int maxId) throws InstagramException {
        Map<String, String> params = new HashMap<String, String>();

        if(minId > 0)
        params.put(QueryParam.MIN_ID, String.valueOf(minId));

        if(maxId > 0)
        params.put(QueryParam.MAX_ID, String.valueOf(maxId));

        String apiMethod = String.format(Methods.TAGS_RECENT_MEDIA, tagName);
        TagMediaFeed feed = createInstagramObject(Verbs.GET, TagMediaFeed.class, apiMethod, null);

        return feed;
    }

Get the remaining API call limit

Hi there,

Instagram developer documentation mentions that each access_token or client_id will have limit up to 5000 API request per hour.
I haven't seen this feature in jInstagram documentation and the code (please correct me if I'm wrong). So, are you planning to add support to get the remaining limit of the Instagram API calls?

jInstagram broken after Instagram API update?

Hello again, Sachin!

IG recently updated their API using a different JSON engin. This resulted in subtle changes in the JSON returned by the API, and I wonder if this might have broken the jInstagram library.

I get an exception in the InstagramAPI class when trying to extract the access token:
OAuthException occured : Cannot extract an acces token. Response was: {"access_token":"4245834.78c27d1.542575764d154b968e96fce......

Cheers
Marius

Pagination through the Followed-By endpoint

Hi, i need to know if there is a way to paginate the followed-by endpoint, using the getUserFollowedByList method, because the first call to this endpoint return just 50 followers.

Thanks in advance

Request Timeout

Hi,
how can I set a timeout on requests?

I noticed that's the method call "setConnectTimeout" in org.jinstagram.http.Request but there's no way to use it.

I suggest to use "InstagramConfig" to pass the timeout value that will be use in org.jinstagram.Instagram.getApiResponse method.

Connection keep alive

It looks like you're disabling http.keepAlive in the Request object. Ass the java specs says, this does affect all other connections as well if I understand the java specs correct. I can't seem to find an easy way to change this in jInstagram so maybe it should be up to the developer using your API if he want to enable/disable http.keepAlive somewhere central in the application???

no check for invalid characters

Hi,

When you query the RecentMediaFeed with a text that includes a '#' character you get back an InstagramException.
When reading out the Exception's message you'll see its a 404.

I think since the tag is substituted inside the URL the URL get's invalid or something.

cheers,
pepijn

Get authenticated users media information

Hi,

I am really sorry if this is the wrong place to post this, but I need help with jInstagram and I have no idea where else to go.

Can anyone point me in the right direction to get the media information of the media that belongs to the user(media id etc.)? I have been searching, but the only thing I can find is information on how to get the users media feed, which is not what I want.

Once again, sorry if this is the wrong place to post this.

Thank you.

Authentification using jInstagram

Hello everyone

I'm trying to use jinstagram I check the wiki and the README.md.
I follow the usage (replace the values for necessary ones) and I get this error

Exception in thread "main" org.jinstagram.auth.exceptions.OAuthException: Cannot extract an acces token. Response was: {"code": 400, "error_type": "OAuthException", "error_message": "No matching code found."}
at org.jinstagram.auth.InstagramApi$1.extract(InstagramApi.java:53)
at org.jinstagram.auth.oauth.InstagramService.getAccessToken(InstagramService.java:53)

Does someone help me with this?

Thank you

Getting api rate limits fails / treat header fields case-insensitive

Hi,

when calling InstagramObject.getAPILimitStatus() / InstagramObject.getRemainingLimitStatus() always -1 is returned. Turns out the implementation of HttpURLConnection (com.google.apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler$Connection) is converting the headers to lower-case and thus looking them up via key in the hashmap fails.

My first thought was to blame the HttpURLConnection implementation. But as it seems http headers are meant to be case-insensitive ( http://stackoverflow.com/questions/5258977/are-http-headers-case-sensitive ). So can't really blame them.

Maybe storing the headers using a java.util.TreeMap with a String.CASE_INSENSITIVE_ORDER comparator could fix this issue? As a quickfix I will work around with InstagramObject.getHeaders().

Regards,
xberger

getRecentMediaFeed() function is not valid?

The getRecentMediaFeed(userId, count, minId, maxId, maxTimeStamp, minTimeStamp) function takes minId and maxId as int values whereas Media Id values for Instagram images exceed that.
Furthermore, the timestamps are supposed to be UNIX timestamps (in seconds) but then the values passed are string equivalent in miliseconds.

Im really confused. Is there any way to use the RAW API using jInstagram?

Request connection should disconnect

Looking through the code I noticed that the connection in Request is never disconnected.
This could be done in doSend() right before the return of the Response

I wouldn't hurt either to setUseCaches to false for the connection

Id's should be String and not long

Taking a look at the returned json from the different endpoints all id's are Strings and not longs. For now all id-strings can be converted to long, but to be future proof it might be better to change id's to String

Pagination through the RecentMediaFeed endpoint

Hi, i want to know if there is a way to use pagination with the RecentMediaFeed. I looked at the examples in the usage page, but i not found any examples in this regard.

Thanks in advance.

Use logging framework

Use logging framework such as slf4j so that we can easily output some debugging information and error messages to log file instead of console.

How to get OAuth Authorization effectively?

Hi,
I try to make an application that shows pictures of some tags in Java.
But I have problem with OAuth!?

I understand from some issues here that verifier code is something like session, and can expire. Every time I run my application I have to get new verifier code!
And this make problem for me, because I have to hard code it each time..

In this moment the application get new verifier code manually each time as this example:
https://gist.github.com/sachin-handiekar/3971607

How can application get verifier code automatically?
Can I use callback link into application? How should I do that?
I just want to make everything in the code and make it simple when you run application.
Is that necessary to use Token and verifier code if I just want to show pictures out of the tags?

Authenticating a User

Awesome library. I'm trying to get a list of the media that a user has liked. So I think that the method that I call is this one:

/**
 * Get the authenticated user's list of media they've liked.
 *
 * @return a MediaFeed object.
 * @throws InstagramException if any error occurs.
 */
public MediaFeed getUserLikedMediaFeed() throws InstagramException {
    MediaFeed userLikedMedia = createInstagramObject(Verbs.GET, MediaFeed.class,
            Methods.USERS_SELF_LIKED_MEDIA, null);

    return userLikedMedia;
}

What I don't understand is:

  • how do I authenticate a user? Is this part of the library?
  • once I authenticate a user, how does this get passed into this function?

Thank you!

Problems parsing json response with "user_has_liked"

Hey Sachin!

Nice work on the jinstagram project!

I am trying out jinstagram and am experiencing a problem when using the getRecentMediaFeed() method.

The json response includes "user_has_liked" info which for some reason has an ID that is a concatenation of the media id, and underscore and the user id:
..."user_has_liked": false, "id": "272980608_4245834", "user": {"username": "mariuswaldal"...

This id triggers an exception as it cannot be parsed to a number:
Caused by: com.google.gson.JsonSyntaxException: java.lang.NumberFormatException: For input string: "272980608_4245834"

Have you experienced this yourself? It might be that the user_has_liked has been added after you last updated jinstagram.

Marius

Error parsing json to object type org.jinstagram.entity.tags.TagMediaFeed

Hi,

First of all thanks for the effort for creating and maintaining the lib!
We are using the lib to scrape instagram feeds based on hashtags. In general it works quite nicely, but I have a weird issue that on some of our servers the scraping of some feeds (not all!) fail with an InstagramException: "Error parsing json to object type org.jinstagram.entity.tags.TagMediaFeed". Now I wonder if this is a configuration issue or something else.

Many thanks,
pepijn

Method Instagram.getRecentMediaTags()

Hi.

This method should use the following query params: min_tag_id and max_tag_id.
Have a look at the documentation: http://instagram.com/developer/endpoints/tags/

In this method you have to pass the params map to createInstagramObject().

public TagMediaFeed getRecentMediaTags(String tagName, long minId, long maxId) throws InstagramException {
    Map<String, String> params = new HashMap<String, String>();

    if (minId > 0) {
        params.put(QueryParam.MIN_TAG_ID, String.valueOf(minId));
    }

    if (maxId > 0) {
        params.put(QueryParam.MAX_TAG_ID, String.valueOf(maxId));
    }

    String apiMethod = String.format(Methods.TAGS_RECENT_MEDIA, tagName);
    TagMediaFeed feed = createInstagramObject(Verbs.GET, TagMediaFeed.class, apiMethod, params);

    return feed;
}

In the QueryParam class I added:

public static final String MAX_TAG_ID = "max_tag_id";
public static final String MIN_TAG_ID = "min_tag_id";

count query parameter and pagination navigation

Looking into the code, seems the 'count' parameter was not there in many places, do you have the plan to add a count parameter, for example, in getUserFeeds method?

Another thing, do you have plan to add method to support pagination, for example, after I call getUserFeeds, then I can call some other method to return the next page based on the 'Pagination' information in the returned user feeds?

Thanks.

errorMeta is null!

Hi,

I got the following stack for all incoming medias since a couple of minutes.

org.jinstagram.exceptions.InstagramException: errorMeta is null!
at org.jinstagram.entity.common.InstagramErrorResponse.throwException(InstagramErrorResponse.java:48)
at org.jinstagram.Instagram.handleInstagramError(Instagram.java:802)
at org.jinstagram.Instagram.createInstagramObject(Instagram.java:792)
at org.jinstagram.Instagram.getRecentMediaTags(Instagram.java:620)

(jInstagram 1.0.7 snapshot)

Usage of setUserHasLiked in MediaFeedData

Guys,
This is not really a bug but more a question regarding usage of API. I am currently testing it to see if I can make all the functionality I will need later.
I was expecting to be able to set a like on a media with something like this:

List mediaFeeds = mediaFeed.getData();
mediaFeeds.get(1).setUserHasLiked(true);

It seems it doesn't work as I would expect. Like is not set and I dont have any exception thrown telling me that I am doing something wrong.

Any idea what I could be doing wrong?

Thanks,
J.

Max Id

Method getUserFeeds(long maxId, long minId, long count) takes type long fod maxId, and maxId can be in format: 410694313788122845_297941864
Method should be:
public MediaFeed getUserFeeds(String maxId, String minId, long count)

Add getErrorType to InstagramException

It would be nice if we could get a getErrorType() on InstagramException, now it concatenates error_type and message into one string and sets this as the error message of the exception, this makes is hard to react properly on the different kinds of errors (error_type).

Expose raw JSON body for jInstagram client

I have a use case where I need to add more fields to the Instagram data that obtained using jInstagram. For example, I need to add location_name field into a media instance which has location_id in it.

In order to effectively handle this use case, I prefer to get raw JSON body so that I can parse it as a map and I can add the new field accordingly.

Alternatively, we can serialize the instance returned by jInstagram into JSON string and deserialize it as a map. But this alternative method is ineffective since we need to perform the conversion twice.

What do you think of this feature? If you're okay, then I can submit a pull request for this feature.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.