Example usage for twitter4j Trend getURL

List of usage examples for twitter4j Trend getURL

Introduction

In this page you can find the example usage for twitter4j Trend getURL.

Prototype

String getURL();

Source Link

Usage

From source file:com.mmiagency.knime.nodes.twitter.util.TrendRow.java

License:Open Source License

private static DataCell[] createCells(final Location location, final Trend trend) {
    List<DataCell> cells = new ArrayList<DataCell>();
    if (location.getCountryName() == null) {
        cells.add(new StringCell(location.getName()));
    } else {/*from   w ww .ja v  a 2  s .co m*/
        cells.add(new StringCell(location.getCountryName() + " - " + location.getName()));
    }
    cells.add(new StringCell(trend.getName()));
    cells.add(new StringCell(trend.getQuery()));
    cells.add(new StringCell(trend.getURL()));
    return cells.toArray(new DataCell[cells.size()]);
}

From source file:org.jwebsocket.plugins.twitter.TwitterPlugIn.java

License:Apache License

private void getTrends(WebSocketConnector aConnector, Token aToken) {
    TokenServer lServer = getServer();/* w  ww  .  ja  v a  2  s . co  m*/

    // instantiate response token
    Token lResponse = lServer.createResponse(aToken);
    String lMsg;

    try {
        if (mLog.isDebugEnabled()) {
            mLog.debug("Retreiving trends...");
        }
        if (!mCheckAuth(lResponse)) {
            mLog.error(lResponse.getString("msg"));
        } else {
            // return the list of messages as an array of strings...
            Map<String, List<String>> lAsOf = new FastMap<String, List<String>>();
            List<String> lMessages;
            ResponseList lTrendList = mTwitter.getDailyTrends();
            for (int lIdx = 0; lIdx < lTrendList.size(); lIdx++) {
                lMessages = new FastList<String>();
                Trends lTrends = (Trends) lTrendList.get(lIdx);
                Trend[] lTrendArray = lTrends.getTrends();
                for (Trend lTrend : lTrendArray) {
                    lMessages.add(lTrend.getName() + ": " + lTrend.getQuery() + ", URL: " + lTrend.getUrl());
                }
                lAsOf.put(Tools.DateToISO8601(lTrends.getTrendAt()), lMessages);
            }
            lResponse.setMap("messages", lAsOf);
            if (mLog.isInfoEnabled()) {
                mLog.info("Trends successfully received");
            }
        }
    } catch (Exception lEx) {
        lMsg = lEx.getClass().getSimpleName() + ": " + lEx.getMessage();
        mLog.error(lMsg);
        lResponse.setInteger("code", -1);
        lResponse.setString("msg", lMsg);
    }

    // send response to requester
    lServer.sendToken(aConnector, lResponse);
}

From source file:project.mum.TwitterTrend.java

public List getTrends(double longi, double lati) throws TwitterException {
    List availableTrends = new ArrayList<String>();

    ConfigurationBuilder cf = new ConfigurationBuilder();
    cf.setDebugEnabled(true).setOAuthConsumerKey("TBFU8jBXiIOEde0cnSglw2m7B")
            .setOAuthConsumerSecret("c0tJVVvGgpY2rI1Ol5qmxzMpB1MiBx8PGlLNPG7TYAAVXwYVvL")
            .setOAuthAccessToken("1148852892-OR8mM62nOH4WPJf991X5bCp4zVKT2EU57fBmjWQ")
            .setOAuthAccessTokenSecret("zpXLqUxlkHZT58RDbGEPLnXVB3Kpwp7d8Z4CKb4X4UJW6");
    TwitterFactory tf = new TwitterFactory(cf.build());
    twitter4j.Twitter twitter = tf.getInstance();
    ResponseList<Location> locations;
    List<MyTrend> myTrend = new ArrayList<MyTrend>();
    MyTrend myTwitterTrend;/*from   w  ww . ja va 2  s.c  om*/
    GeoLocation geo = new GeoLocation(longi, lati);
    locations = twitter.getClosestTrends(geo);
    Trends trends = twitter.getPlaceTrends(locations.get(0).getWoeid());
    int count = 0;
    for (Trend trend : trends.getTrends()) {
        if (count < 5) {
            myTwitterTrend = new MyTrend(trend.getName(), trend.getURL());
            myTrend.add(myTwitterTrend);
            count++;
            availableTrends.add(trend.getName());
        }
    }
    System.out.println(" available Trends :" + availableTrends);
    return myTrend;
}