コード例 #1
0
 /**
  * User Streams provides real-time updates of all data needed to update a desktop application
  * display. Applications can request startup back-fill from the REST API and then transition to
  * Streaming for nearly all subsequent reads. Rate limits and latency are practically eliminated.
  * Desktop developers can stop managing rate limits and use this new data to create an entirely
  * new user experience. On our end, we hope to reduce costs and increase site reliability.
  *
  * @param track keywords to track
  * @return UserStream
  * @throws TwitterException when Twitter service or network is unavailable
  * @see <a href="https://dev.twitter.com/docs/streaming-api/user-streams">User Streams</a>
  * @since Twitter4J 2.1.9
  */
 UserStream getUserStream(String[] track) throws TwitterException {
   ensureAuthorizationEnabled();
   try {
     List<HttpParameter> params = new ArrayList<HttpParameter>();
     params.add(stallWarningsParam);
     if (conf.isUserStreamRepliesAllEnabled()) {
       params.add(new HttpParameter("replies", "all"));
     }
     if (!conf.isUserStreamWithFollowingsEnabled()) {
       params.add(new HttpParameter("with", "user"));
     }
     if (track != null) {
       params.add(new HttpParameter("track", StringUtil.join(track)));
     }
     return new UserStreamImpl(
         getDispatcher(),
         http.post(
             conf.getUserStreamBaseURL() + "user.json",
             params.toArray(new HttpParameter[params.size()]),
             auth,
             null),
         conf);
   } catch (IOException e) {
     throw new TwitterException(e);
   }
 }
コード例 #2
0
 InputStream getSiteStream(boolean withFollowings, long[] follow) throws TwitterException {
   ensureOAuthEnabled();
   return http.post(
           conf.getSiteStreamBaseURL() + "site.json",
           new HttpParameter[] {
             new HttpParameter("with", withFollowings ? "followings" : "user"),
             new HttpParameter("follow", StringUtil.join(follow)),
             stallWarningsParam
           },
           auth,
           null)
       .asStream();
 }
コード例 #3
0
  public void groupInsert() {
    int check = 0;
    for (int i = 0; i < people_adapter_list.isCheckedConfrim.length; i++) {
      if (people_adapter_list.isCheckedConfrim[i] == true) {
        check++;
      }
    }

    Log.d("people_gram", String.valueOf(check));

    if (check != 0) {
      RequestParams params = new RequestParams();
      params.put("uid", SharedPreferenceUtil.getSharedPreference(GroupWriteActivity.this, "uid"));
      params.put(
          "username",
          SharedPreferenceUtil.getSharedPreference(GroupWriteActivity.this, "username"));
      params.put("group_code", group_code);
      // params.put("group_name", group_name.getText().toString());
      params.put("people_uid", people_adapter_list.uid_check);
      params.put("people_username", people_adapter_list.username_check);

      HttpClient.post(
          "/group/groupWrite",
          params,
          new AsyncHttpResponseHandler() {
            public void onStart() {
              dialog = ProgressDialog.show(GroupWriteActivity.this, "", "데이터 수신중");
            }

            public void onFailure() {}

            public void onFinish() {
              dialog.dismiss();
            }

            @Override
            public void onSuccess(String response) {
              Log.d("people_gram", response);
              if (response.equals("000")) {
                Intent intent = new Intent();
                setResult(41, intent);
                finish();
              }
              // Log.d("people_gram", response);
            }
          });
    } else {
      Toast.makeText(GroupWriteActivity.this, "그룹에 등록할 피플을 선택해주세요.", Toast.LENGTH_LONG).show();
    }
  }
コード例 #4
0
 /**
  * Returns public statuses that match one or more filter predicates. At least one predicate
  * parameter, follow, locations, or track must be specified. Multiple parameters may be specified
  * which allows most clients to use a single connection to the Streaming API. Placing long
  * parameters in the URL may cause the request to be rejected for excessive URL length.<br>
  * The default access level allows up to 200 track keywords, 400 follow userids and 10 1-degree
  * location boxes. Increased access levels allow 80,000 follow userids ("shadow" role), 400,000
  * follow userids ("birddog" role), 10,000 track keywords ("restricted track" role), 200,000 track
  * keywords ("partner track" role), and 200 10-degree location boxes ("locRestricted" role).
  * Increased track access levels also pass a higher proportion of statuses before limiting the
  * stream.
  *
  * @param query Filter query
  * @return StatusStream
  * @throws TwitterException when Twitter service or network is unavailable
  * @see twitter4j.StatusStream
  * @see <a href="https://dev.twitter.com/docs/streaming-api/methods">Streaming API Methods |
  *     Twitter Developers</a>
  * @since Twitter4J 2.1.2
  */
 StatusStream getFilterStream(FilterQuery query) throws TwitterException {
   ensureAuthorizationEnabled();
   try {
     return new StatusStreamImpl(
         getDispatcher(),
         http.post(
             conf.getStreamBaseURL() + "statuses/filter.json",
             query.asHttpParameterArray(stallWarningsParam),
             auth,
             null),
         conf);
   } catch (IOException e) {
     throw new TwitterException(e);
   }
 }
コード例 #5
0
 /**
  * Returns a stream of all retweets. The retweet stream is not a generally available resource. Few
  * applications require this level of access. Creative use of a combination of other resources and
  * various access levels can satisfy nearly every application use case. As of 9/11/2009, the
  * site-wide retweet feature has not yet launched, so there are currently few, if any, retweets on
  * this stream.
  *
  * @return StatusStream
  * @throws TwitterException when Twitter service or network is unavailable
  * @see twitter4j.StatusStream
  * @see <a href="https://dev.twitter.com/docs/streaming-api/methods">Streaming API: Methods
  *     statuses/retweet</a>
  * @since Twitter4J 2.0.10
  */
 StatusStream getRetweetStream() throws TwitterException {
   ensureAuthorizationEnabled();
   try {
     return new StatusStreamImpl(
         getDispatcher(),
         http.post(
             conf.getStreamBaseURL() + "statuses/retweet.json",
             new HttpParameter[] {stallWarningsParam},
             auth,
             null),
         conf);
   } catch (IOException e) {
     throw new TwitterException(e);
   }
 }
コード例 #6
0
 private StatusStream getCountStream(String relativeUrl, int count) throws TwitterException {
   ensureAuthorizationEnabled();
   try {
     return new StatusStreamImpl(
         getDispatcher(),
         http.post(
             conf.getStreamBaseURL() + relativeUrl,
             new HttpParameter[] {
               new HttpParameter("count", String.valueOf(count)), stallWarningsParam
             },
             auth,
             null),
         conf);
   } catch (IOException e) {
     throw new TwitterException(e);
   }
 }
コード例 #7
0
ファイル: OAuthProcess.java プロジェクト: clawplach/jwt
 void requestToken(String authorizationCode) {
   try {
     String url = this.service_.getTokenEndpoint();
     StringBuilder ss = new StringBuilder();
     ss.append("grant_type=authorization_code")
         .append("&client_id=")
         .append(Utils.urlEncode(this.service_.getClientId()))
         .append("&client_secret=")
         .append(Utils.urlEncode(this.service_.getClientSecret()))
         .append("&redirect_uri=")
         .append(Utils.urlEncode(this.service_.getGenerateRedirectEndpoint()))
         .append("&code=")
         .append(authorizationCode);
     HttpClient client = new HttpClient(this);
     client.setTimeout(15);
     client
         .done()
         .addListener(
             this,
             new Signal2.Listener<Exception, HttpMessage>() {
               public void trigger(Exception event1, HttpMessage event2) {
                 OAuthProcess.this.handleToken(event1, event2);
               }
             });
     Method m = this.service_.getTokenRequestMethod();
     if (m == Method.Get) {
       boolean hasQuery = url.indexOf('?') != -1;
       url += (hasQuery ? '&' : '?') + ss.toString();
       client.get(url);
     } else {
       HttpMessage post = new HttpMessage();
       post.setHeader("Content-Type", "application/x-www-form-urlencoded");
       post.addBodyText(ss.toString());
       client.post(url, post);
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
コード例 #8
0
  /**
   * Processes the request and returns an AuthorizeResponse. This service causes a
   * GenericServiceException if there is a fatal confguration error that must be addressed.
   */
  private static AuthorizeResponse processRequest(Map request, String resource)
      throws GenericServiceException {
    boolean testMode = isTestMode(resource);
    String url = UtilProperties.getPropertyValue(resource, "payment.authorizedotnet.url");
    if (UtilValidate.isEmpty(url)) {
      throw new GenericServiceException(
          "Authorize.NET transaction URL not configured.  Please ensure payment.authorizedotnet.test is defined in "
              + resource);
    }

    Debug.logInfo("Sending eCheck.NET request type " + request.get("x_type"), module);
    if (testMode) {
      Debug.logInfo("Request URL: " + url, module);
      Debug.logInfo("Request Map: " + request, module);
    }

    // post the request to the url
    String responseString = null;
    try {
      HttpClient client = new HttpClient(url, request);
      client.setClientCertificateAlias("AUTHORIZE_NET");
      responseString = client.post();
    } catch (HttpClientException e) {
      Debug.logError(
          e,
          "Failed to send eCheck.NET request due to client exception: " + e.getMessage(),
          module);
      return null;
    }

    if (testMode) {
      Debug.logInfo("Response from eCheck.NET: " + responseString, module);
    }

    return new AuthorizeResponse(responseString);
  }
コード例 #9
0
  private void peopleList() {
    Log.d("people_gram", "성공");
    people_dto_list = new ArrayList<SubGroupPeopleListDTO>();
    people_dto_list_temp = new ArrayList<SubGroupPeopleListDTO_Temp>();
    RequestParams params = new RequestParams();
    params.put("uid", SharedPreferenceUtil.getSharedPreference(GroupWriteActivity.this, "uid"));
    params.put("group_code", group_code);
    // params.put("searchType", searchType);
    HttpClient.post(
        "/group/groupPeopleList",
        params,
        new AsyncHttpResponseHandler() {
          public void onStart() {
            dialog = ProgressDialog.show(GroupWriteActivity.this, "", "데이터 수신중");
          }

          public void onFailure() {}

          public void onFinish() {
            dialog.dismiss();
          }

          @Override
          public void onSuccess(String response) {
            Log.d("people_gram", response);
            try {

              JSONObject data = new JSONObject(response);
              JSONArray people_list = data.getJSONArray("people");

              for (int i = 0; i < people_list.length(); i++) {
                JSONObject jobj = people_list.getJSONObject(i);

                String email = "";
                String type = "";
                String gubun1 = "";
                String gubun2 = "";
                int speed = 0;
                int control = 0;

                if (jobj.getString("JOIN_EMAIL") != "null") {
                  email = jobj.getString("JOIN_EMAIL");
                } else {
                  email = "미가입";
                }
                if (jobj.getString("YOU_TYPE") != "null") {
                  type = jobj.getString("YOU_TYPE");
                }
                if (jobj.getString("GUBUN1") != "null") {
                  gubun1 = jobj.getString("GUBUN1");
                }
                if (jobj.getString("GUBUN2") != "null") {
                  gubun2 = jobj.getString("GUBUN2");
                }

                if (jobj.getString("SPEED") != "null") {
                  speed = Integer.parseInt(jobj.getString("SPEED"));
                }
                if (jobj.getString("CONTROL") != "null") {
                  control = Integer.parseInt(jobj.getString("CONTROL"));
                }

                people_dto_list.add(
                    new SubGroupPeopleListDTO(
                        jobj.getString("UID"),
                        "",
                        jobj.getString("PEOPLE_USERNAME"),
                        email,
                        type,
                        "",
                        gubun1,
                        gubun2,
                        speed,
                        control,
                        jobj.getInt("GROUP_COUNT"),
                        false));

                people_dto_list_temp.add(
                    new SubGroupPeopleListDTO_Temp(
                        jobj.getString("UID"),
                        "",
                        jobj.getString("PEOPLE_USERNAME"),
                        email,
                        type,
                        "",
                        gubun1,
                        gubun2,
                        speed,
                        control,
                        jobj.getInt("GROUP_COUNT"),
                        false));
              }

              people_adapter_list =
                  new SubGroupPeopleListAdapter(
                      GroupWriteActivity.this, R.layout.sub_group_people_row_list, people_dto_list);
              sf_people_list.setAdapter(people_adapter_list);

            } catch (JSONException e) {
              e.printStackTrace();
            }
          }
        });
  }