Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Tests of the added date ranges for some API calls #1389

Closed
wants to merge 10 commits into from

4 participants

@danipena

Tests of API date range calls for: user_mentions, user_questions, user_replies and post_replies.

Following up on your comments from (#1378)

  • Contains the tests that were not included for the added calls in the previous pull request on 'tests/PostMySQLDAO'.
  • Code is pretty straightforward and tries to follow existing style.

Please let me know if all is correct.

Thanks!

Powered by Televisió de Catalunya - SOCIALMEDIA PROJECT - CEN-20101037 - This contribution has been kindly sponsored by the Centro para el Desarrollo Tecnológico Industrial within the Programa de Investigación Nacional Español CENIT. - http://www.cenitsocialmedia.es/

danipena and others added some commits
@danipena danipena Added date ranges for some API calls
API date range calls for: user_mentions, user_questions, user_replies and
post replies.

Cleaned up code formatting n' stuff. Contains appropriate tests and
documentation for the added calls. Code is pretty straightforward.

API calls do not have a configurable count limit, following up on the
philosophy for the other range calls. Documentation has been tweaked
to reflect this.
5b3e0ed
@KZeni KZeni Fix "1103 Incorrect table name" error
Fixed problem where the database update/migration would fail on databases that don't allow periods in table names. Discussion: ThinkUpLLC#1377
38ed2b8
@ginatrapani ginatrapani Twitter plugin: Avoid illegal offset type error during crawl 5dae34c
@ginatrapani ginatrapani Fix transient TestOfPluginController::testUpdateDeletePluginOption fa…
…ilure
1b46f86
@ginatrapani ginatrapani Activate Foursquare plugin on installation by default 330e140
@ginatrapani ginatrapani Version 1.1.1 b6ed1c0
@CDainMiller CDainMiller Cleaned up first two JavaScript files. Added missing semi-colons and …
…added != where should have been !== in only two cases. No other changes were made to code.
a3c25c9
@danipena danipena Merge branch 'master' of https://github.com/ginatrapani/ThinkUp
Download the newest version of ThinkUp to local
b34cfc7
@danipena danipena Tests of the added date ranges for some API calls
Tests of API date range calls for: user_mentions, user_questions, user_replies and post_replies.

Following up on your comments from (ThinkUpLLC#1378)

* Contains the tests for the added calls that were not included in the previous pull request on 'tests/PostMySQLDAO'.
* Code is pretty straightforward and tries to follow existing style.

Please let me know if all is correct.

Thanks!

Powered by Televisi� de Catalunya - SOCIALMEDIA PROJECT - CEN-20101037 - This contribution has been kindly sponsored by the Centro para el Desarrollo Tecnol�gico Industrial within the Programa de Investigaci�n Nacional Espa�ol CENIT. - http://www.cenitsocialmedia.es/
35e44d2
@danipena danipena Tests of the added date ranges for some API calls
Tests of API date range calls for: user_mentions, user_questions, user_replies and post_replies.

Following up on your comments from (ThinkUpLLC#1378)

Contains the tests that were not included for the added calls in the previous pull request on 'tests/PostMySQLDAO'.
Code is pretty straightforward and tries to follow existing style.

Please let me know if all is correct.

Thanks!

Powered by Televisi� de Catalunya - SOCIALMEDIA PROJECT - CEN-20101037 - This contribution has been kindly sponsored by the Centro para el Desarrollo Tecnol�gico Industrial within the Programa de Investigaci�n Nacional Espa�ol CENIT. - http://www.cenitsocialmedia.es/
250ee09
@danipena

Hi Gina,

Do you need anything else where I could help you on this API methods? I am ready to keep on working and contributing to ThinkUp!

Best wishes,

Dani

@ginatrapani
Owner

Hi Dani--apologies for the delay, my daughter was born a few weeks ago so I've been slow to handle incoming pull requests.

Looks like all your tests are complete and passing, which is wonderful. I will merge this into master.

Before I do, I did have to do some cleanup and corrections. In the future, some guidelines to keep in mind when you're working on ThinkUp code:

I fixed that in 50da8fc

We appreciate all the work you've done on this. Thanks!

@ginatrapani ginatrapani closed this pull request from a commit
@danipena danipena Added Post API date range calls for: user_mentions, user_questions, u…
…ser_replies and post replies.

Contains appropriate tests and documentation for the added calls.

API calls do not have a configurable count limit, following up on the philosophy for the other range calls. Documentation has been tweaked to reflect this.

Closes #1389
018ea8d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 10, 2012
  1. @danipena

    Added date ranges for some API calls

    danipena authored
    API date range calls for: user_mentions, user_questions, user_replies and
    post replies.
    
    Cleaned up code formatting n' stuff. Contains appropriate tests and
    documentation for the added calls. Code is pretty straightforward.
    
    API calls do not have a configurable count limit, following up on the
    philosophy for the other range calls. Documentation has been tweaked
    to reflect this.
Commits on Sep 20, 2012
  1. @KZeni @danipena

    Fix "1103 Incorrect table name" error

    KZeni authored danipena committed
    Fixed problem where the database update/migration would fail on databases that don't allow periods in table names. Discussion: ThinkUpLLC#1377
  2. @ginatrapani @danipena
  3. @ginatrapani @danipena
  4. @ginatrapani @danipena

    Activate Foursquare plugin on installation by default

    ginatrapani authored danipena committed
  5. @ginatrapani @danipena

    Version 1.1.1

    ginatrapani authored danipena committed
  6. @CDainMiller @danipena

    Cleaned up first two JavaScript files. Added missing semi-colons and …

    CDainMiller authored danipena committed
    …added != where should have been !== in only two cases. No other changes were made to code.
  7. @danipena

    Merge branch 'master' of https://github.com/ginatrapani/ThinkUp

    danipena authored
    Download the newest version of ThinkUp to local
Commits on Sep 25, 2012
  1. @danipena

    Tests of the added date ranges for some API calls

    danipena authored
    Tests of API date range calls for: user_mentions, user_questions, user_replies and post_replies.
    
    Following up on your comments from (ThinkUpLLC#1378)
    
    * Contains the tests for the added calls that were not included in the previous pull request on 'tests/PostMySQLDAO'.
    * Code is pretty straightforward and tries to follow existing style.
    
    Please let me know if all is correct.
    
    Thanks!
    
    Powered by Televisi� de Catalunya - SOCIALMEDIA PROJECT - CEN-20101037 - This contribution has been kindly sponsored by the Centro para el Desarrollo Tecnol�gico Industrial within the Programa de Investigaci�n Nacional Espa�ol CENIT. - http://www.cenitsocialmedia.es/
Commits on Sep 26, 2012
  1. @danipena

    Tests of the added date ranges for some API calls

    danipena authored
    Tests of API date range calls for: user_mentions, user_questions, user_replies and post_replies.
    
    Following up on your comments from (ThinkUpLLC#1378)
    
    Contains the tests that were not included for the added calls in the previous pull request on 'tests/PostMySQLDAO'.
    Code is pretty straightforward and tries to follow existing style.
    
    Please let me know if all is correct.
    
    Thanks!
    
    Powered by Televisi� de Catalunya - SOCIALMEDIA PROJECT - CEN-20101037 - This contribution has been kindly sponsored by the Centro para el Desarrollo Tecnol�gico Industrial within the Programa de Investigaci�n Nacional Espa�ol CENIT. - http://www.cenitsocialmedia.es/
This page is out of date. Refresh to see the latest.
View
223 docs/source/userguide/api/posts/post_replies_in_range.rst
@@ -0,0 +1,223 @@
+Post Replies
+============
+Gets the replies to a post in a given time range.
+
+**API call type slug:** ``post_replies_in_range``
+
+**Example Usage:** ``api/v1/post.php?type=post_replies_in_range&from=29-03-2011&until=04-04-2011&post_id=12345``
+
+==================
+Required arguments
+==================
+
+* **post_id**
+
+ The ID of the post to retrieve replies to.
+
+* **from**
+
+ The date/time to start searching from. This can either be a
+ `valid date string <http://www.php.net/manual/en/datetime.formats.php>`_ or a Unix timestamp.
+
+* **until**
+
+ The date/time to search until. This can either be a
+ `valid date string <http://www.php.net/manual/en/datetime.formats.php>`_ or a Unix timestamp.
+
+==================
+Optional Arguments
+==================
+
+* **network**
+
+ The network to use in the call. Defaults to 'twitter'.
+
+* **order_by**
+
+ The column to order the results by. Defaults to chronological order ("date"). The default direction to order
+ results from this call are descending.
+
+* **unit**
+
+ Sets the unit of measurement to return the ``reply_retweet_distance`` in. Can be either "mi" for miles or "km"
+ for kilometres. Defaults to "km".
+
+* **include_entities**
+
+ Whether or not to include `Tweet Entities <http://dev.twitter.com/pages/tweet_entities>`_ in the output. Defaults
+ to false. This argument can be set to true by making it equal to either **1**, **t** or **true**.
+
+* **include_replies**
+
+ Whether or not to include replies to this post in the output. This argument is recursive and will retrieve replies
+ to replies also. Defaults to false. This argument can be set to true by making it equal to either **1**, **t** or
+ **true**.
+
+* **trim_user**
+
+ If set to true, this flag strips the user part of the output to just the user's ID and nothing else. Defaults to
+ false. This argument can be set to true by making it equal to either **1**, **t** or **true**.
+
+.. warning::
+ The method 'post_replies_in_range', along with user_replies_in_range, user_questions_in_range,
+ user_mentions_in_range and user_posts_in_range are the ThinkUp Post API methods which do not enforce a cap of
+ 200 post results returned per call.
+ As such, when querying time ranges which contain more than 200 posts, keep in mind that processing that amount of
+ data may exceed your server's memory limits.
+
+==============
+Example output
+==============
+
+``/api/v1/post.php?type=post_replies_in_range&post_id=242576686674223106&from=2012-09-03T11:00:00GMT+02:00&until=2012-09-03T017:00:00%20GMT+02:00&include_entities=t&include_replies=t``::
+
+
+
+[
+ {
+ "id":242578744764690432,
+ "author_follower_count":null,
+ "source":"web",
+ "location":"Tordera-Barcelona",
+ "place":null,
+ "place_id":null,
+ "geo":null,
+ "in_reply_to_user_id":227641758,
+ "in_reply_to_post_id":242576686674223106,
+ "is_reply_by_friend":false,
+ "is_retweet_by_friend":false,
+ "reply_retweet_distance":0,
+ "in_rt_of_user_id":null,
+ "retweet_count_api":0,
+ "favlike_count_cache":0,
+ "links":[
+
+ ],
+ "favorited":false,
+ "all_retweets":0,
+ "text":"@penia19 #fcb",
+ "created_at":"Mon Sep 03 11:04:14 +0200 2012",
+ "annotations":null,
+ "truncated":false,
+ "protected":false,
+ "thinkup":{
+ "retweet_count_cache":0,
+ "retweet_count_api":0,
+ "reply_count_cache":0,
+ "old_retweet_count_cache":0,
+ "is_geo_encoded":0
+ },
+ "user":{
+ "id":256559225,
+ "location":"Tordera-Barcelona",
+ "description":"Llicenciada en Ci\u00e8ncies Pol\u00edtiques i de l'Administraci\u00f3, a la Universtat Pompeu Fabra. Membre de la JNC, Deba-t i R\u00e0dio Tordera",
+ "url":"",
+ "friend_count":520,
+ "last_updated":"2012-09-03 13:23:58",
+ "followers_count":283,
+ "profile_image_url":"http://a0.twimg.com/profile_images/2169909420/ji_normal.jpg",
+ "name":"Judith",
+ "screen_name":"judithtoronjo",
+ "statuses_count":585,
+ "created_at":"Wed Feb 23 15:58:39 +0100 2011",
+ "avg_tweets_per_day":1.05,
+ "thinkup":{
+ "last_post":"0000-00-00 00:00:00",
+ "last_post_id":"",
+ "found_in":"mentions"
+ }
+ },
+ "entities":{
+ "hashtags":[
+ {
+ "text":"fcb",
+ "indices":[
+ 9,
+ 13
+ ]
+ }
+ ],
+ "user_mentions":[
+ {
+ "name":"Daniel Pe\u00f1a Pizarro",
+ "id":227641758,
+ "screen_name":"penia19",
+ "indices":[
+ 0,
+ 8
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "id":242579576025403392,
+ "author_follower_count":null,
+ "source":"web",
+ "location":"Barcelona",
+ "place":null,
+ "place_id":null,
+ "geo":null,
+ "in_reply_to_user_id":227641758,
+ "in_reply_to_post_id":242576686674223106,
+ "is_reply_by_friend":false,
+ "is_retweet_by_friend":false,
+ "reply_retweet_distance":0,
+ "in_rt_of_user_id":null,
+ "retweet_count_api":0,
+ "favlike_count_cache":0,
+ "links":[
+
+ ],
+ "favorited":false,
+ "all_retweets":0,
+ "text":"@penia19 me too!",
+ "created_at":"Mon Sep 03 11:07:32 +0200 2012",
+ "annotations":null,
+ "truncated":false,
+ "protected":false,
+ "thinkup":{
+ "retweet_count_cache":0,
+ "retweet_count_api":0,
+ "reply_count_cache":0,
+ "old_retweet_count_cache":0,
+ "is_geo_encoded":0
+ },
+ "user":{
+ "id":302708860,
+ "location":"Barcelona",
+ "description":"Research Project Manager @ TVC - I never think of the future. It comes soon enough. Albert Einstein\n",
+ "url":"http://es.linkedin.com/in/eusebiocarasusan",
+ "friend_count":247,
+ "last_updated":"2012-09-03 13:23:58",
+ "followers_count":113,
+ "profile_image_url":"http://a0.twimg.com/profile_images/2432460341/810fonvgxd8c9z65pgdi_normal.jpeg",
+ "name":"Eusebio Carasus\u00e1n",
+ "screen_name":"ecarasusan",
+ "statuses_count":417,
+ "created_at":"Sat May 21 16:40:17 +0200 2011",
+ "avg_tweets_per_day":0.89,
+ "thinkup":{
+ "last_post":"2012-08-23 17:51:19",
+ "last_post_id":"",
+ "found_in":"mentions"
+ }
+ },
+ "entities":{
+ "hashtags":[
+
+ ],
+ "user_mentions":[
+ {
+ "name":"Daniel Pe\u00f1a Pizarro",
+ "id":227641758,
+ "screen_name":"penia19",
+ "indices":[
+ 0,
+ 8
+ ]
+ }
+ ]
+ }
+ }
+]
View
518 docs/source/userguide/api/posts/user_mentions_in_range.rst
@@ -0,0 +1,518 @@
+User Mentions
+=============
+Gets posts that a user is mentioned in a given time range.
+
+**API call type slug:** ``user_mentions_in_range``
+
+**Example Usage:** ``api/v1/post.php?type=user_mentions_in_range&from=29-03-2011&until=04-04-2011&username=samwhoo``
+
+==================
+Required arguments
+==================
+
+* **user_id** or **username**
+
+ Only one of these is required. They are to specify the user to gather posts for in this call.
+
+* **from**
+
+ The date/time to start searching from. This can either be a
+ `valid date string <http://www.php.net/manual/en/datetime.formats.php>`_ or a Unix timestamp.
+
+* **until**
+
+ The date/time to search until. This can either be a
+ `valid date string <http://www.php.net/manual/en/datetime.formats.php>`_ or a Unix timestamp.
+
+
+==================
+Optional Arguments
+==================
+
+* **network**
+
+ The network to use in the call. Defaults to 'twitter'.
+
+* **order_by**
+
+ The column to order the results by. Defaults to chronological order ("date").
+
+* **direction**
+
+ The direction to order the results in. Can be either DESC or ASC. Defaults to DESC.
+
+* **include_rts**
+
+ Whether or not to include retweets as mentions. Defaults to false. This argument can be set to true by making it
+ equal to either **1**, **t** or **true**.
+
+* **include_entities**
+
+ Whether or not to include `Tweet Entities <http://dev.twitter.com/pages/tweet_entities>`_ in the output. Defaults
+ to false. This argument can be set to true by making it equal to either **1**, **t** or **true**.
+
+* **include_replies**
+
+ Whether or not to include replies to this post in the output. This argument is recursive and will retrieve replies
+ to replies also. Defaults to false. This argument can be set to true by making it equal to either **1**, **t** or
+ **true**.
+
+* **trim_user**
+
+ If set to true, this flag strips the user part of the output to just the user's ID and nothing else. Defaults to
+ false. This argument can be set to true by making it equal to either **1**, **t** or **true**.
+
+.. warning::
+ The method 'user_mentions_in_range', along with user_replies_in_range, post_replies_in_range,
+ user_questions_in_range and user_posts_in_range are the ThinkUp Post API methods which do not enforce a cap of
+ 200 post results returned per call.
+ As such, when querying time ranges which contain more than 200 posts, keep in mind that processing that amount of
+ data may exceed your server's memory limits.
+
+==============
+Example output
+==============
+
+``/api/v1/post.php?type=user_mentions_in_range&username=penia19&from=2012-09-03T11:00:00GMT+02:00&until=2012-09-03T017:00:00%20GMT+02:00&include_entities=t&include_replies=t``::
+
+[
+ {
+ "id":242580106491596801,
+ "author_follower_count":null,
+ "source":"web",
+ "location":"Barcelona",
+ "place":null,
+ "place_id":null,
+ "geo":null,
+ "in_reply_to_user_id":null,
+ "in_reply_to_post_id":null,
+ "is_reply_by_friend":false,
+ "is_retweet_by_friend":false,
+ "reply_retweet_distance":0,
+ "in_rt_of_user_id":null,
+ "retweet_count_api":0,
+ "favlike_count_cache":0,
+ "links":[
+
+ ],
+ "favorited":false,
+ "all_retweets":0,
+ "text":"1.500 alojamientos rurales han echado el cierre este a\u00f1o http://t.co/ZxbcJAqt Qu\u00e8 tal per les terres de Lleida @penia19 ?",
+ "created_at":"Mon Sep 03 11:09:38 +0200 2012",
+ "annotations":null,
+ "truncated":false,
+ "protected":false,
+ "thinkup":{
+ "retweet_count_cache":0,
+ "retweet_count_api":0,
+ "reply_count_cache":0,
+ "old_retweet_count_cache":0,
+ "is_geo_encoded":0
+ },
+ "user":{
+ "id":302708860,
+ "location":"Barcelona",
+ "description":"Research Project Manager @ TVC - I never think of the future. It comes soon enough. Albert Einstein\n",
+ "url":"http://es.linkedin.com/in/eusebiocarasusan",
+ "friend_count":247,
+ "last_updated":"2012-09-03 13:23:58",
+ "followers_count":113,
+ "profile_image_url":"http://a0.twimg.com/profile_images/2432460341/810fonvgxd8c9z65pgdi_normal.jpeg",
+ "name":"Eusebio Carasus\u00e1n",
+ "screen_name":"ecarasusan",
+ "statuses_count":417,
+ "created_at":"Sat May 21 16:40:17 +0200 2011",
+ "avg_tweets_per_day":0.89,
+ "thinkup":{
+ "last_post":"2012-08-23 17:51:19",
+ "last_post_id":"",
+ "found_in":"mentions"
+ }
+ },
+ "entities":{
+ "hashtags":[
+
+ ],
+ "user_mentions":[
+ {
+ "name":"Daniel Pe\u00f1a Pizarro",
+ "id":227641758,
+ "screen_name":"penia19",
+ "indices":[
+ 113,
+ 121
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "id":242579576025403392,
+ "author_follower_count":null,
+ "source":"web",
+ "location":"Barcelona",
+ "place":null,
+ "place_id":null,
+ "geo":null,
+ "in_reply_to_user_id":227641758,
+ "in_reply_to_post_id":242576686674223106,
+ "is_reply_by_friend":false,
+ "is_retweet_by_friend":false,
+ "reply_retweet_distance":0,
+ "in_rt_of_user_id":null,
+ "retweet_count_api":0,
+ "favlike_count_cache":0,
+ "links":[
+
+ ],
+ "favorited":false,
+ "all_retweets":0,
+ "text":"@penia19 me too!",
+ "created_at":"Mon Sep 03 11:07:32 +0200 2012",
+ "annotations":null,
+ "truncated":false,
+ "protected":false,
+ "thinkup":{
+ "retweet_count_cache":0,
+ "retweet_count_api":0,
+ "reply_count_cache":0,
+ "old_retweet_count_cache":0,
+ "is_geo_encoded":0
+ },
+ "user":{
+ "id":302708860,
+ "location":"Barcelona",
+ "description":"Research Project Manager @ TVC - I never think of the future. It comes soon enough. Albert Einstein\n",
+ "url":"http://es.linkedin.com/in/eusebiocarasusan",
+ "friend_count":247,
+ "last_updated":"2012-09-03 13:23:58",
+ "followers_count":113,
+ "profile_image_url":"http://a0.twimg.com/profile_images/2432460341/810fonvgxd8c9z65pgdi_normal.jpeg",
+ "name":"Eusebio Carasus\u00e1n",
+ "screen_name":"ecarasusan",
+ "statuses_count":417,
+ "created_at":"Sat May 21 16:40:17 +0200 2011",
+ "avg_tweets_per_day":0.89,
+ "thinkup":{
+ "last_post":"2012-08-23 17:51:19",
+ "last_post_id":"",
+ "found_in":"mentions"
+ }
+ },
+ "entities":{
+ "hashtags":[
+
+ ],
+ "user_mentions":[
+ {
+ "name":"Daniel Pe\u00f1a Pizarro",
+ "id":227641758,
+ "screen_name":"penia19",
+ "indices":[
+ 0,
+ 8
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "id":242579461676101632,
+ "author_follower_count":null,
+ "source":"web",
+ "location":"Barcelona",
+ "place":null,
+ "place_id":null,
+ "geo":null,
+ "in_reply_to_user_id":227641758,
+ "in_reply_to_post_id":242576991033888768,
+ "is_reply_by_friend":false,
+ "is_retweet_by_friend":false,
+ "reply_retweet_distance":0,
+ "in_rt_of_user_id":null,
+ "retweet_count_api":0,
+ "favlike_count_cache":0,
+ "links":[
+
+ ],
+ "favorited":false,
+ "all_retweets":0,
+ "text":"@penia19 he's gonna win a lot of titles with FCB",
+ "created_at":"Mon Sep 03 11:07:05 +0200 2012",
+ "annotations":null,
+ "truncated":false,
+ "protected":false,
+ "thinkup":{
+ "retweet_count_cache":0,
+ "retweet_count_api":0,
+ "reply_count_cache":0,
+ "old_retweet_count_cache":0,
+ "is_geo_encoded":0
+ },
+ "user":{
+ "id":302708860,
+ "location":"Barcelona",
+ "description":"Research Project Manager @ TVC - I never think of the future. It comes soon enough. Albert Einstein\n",
+ "url":"http://es.linkedin.com/in/eusebiocarasusan",
+ "friend_count":247,
+ "last_updated":"2012-09-03 13:23:58",
+ "followers_count":113,
+ "profile_image_url":"http://a0.twimg.com/profile_images/2432460341/810fonvgxd8c9z65pgdi_normal.jpeg",
+ "name":"Eusebio Carasus\u00e1n",
+ "screen_name":"ecarasusan",
+ "statuses_count":417,
+ "created_at":"Sat May 21 16:40:17 +0200 2011",
+ "avg_tweets_per_day":0.89,
+ "thinkup":{
+ "last_post":"2012-08-23 17:51:19",
+ "last_post_id":"",
+ "found_in":"mentions"
+ }
+ },
+ "entities":{
+ "hashtags":[
+
+ ],
+ "user_mentions":[
+ {
+ "name":"Daniel Pe\u00f1a Pizarro",
+ "id":227641758,
+ "screen_name":"penia19",
+ "indices":[
+ 0,
+ 8
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "id":242578915867111424,
+ "author_follower_count":null,
+ "source":"web",
+ "location":"Tordera-Barcelona",
+ "place":null,
+ "place_id":null,
+ "geo":null,
+ "in_reply_to_user_id":227641758,
+ "in_reply_to_post_id":242576991033888768,
+ "is_reply_by_friend":false,
+ "is_retweet_by_friend":false,
+ "reply_retweet_distance":0,
+ "in_rt_of_user_id":null,
+ "retweet_count_api":0,
+ "favlike_count_cache":0,
+ "links":[
+
+ ],
+ "favorited":false,
+ "all_retweets":0,
+ "text":"@penia19 I don't like Alex Song",
+ "created_at":"Mon Sep 03 11:04:55 +0200 2012",
+ "annotations":null,
+ "truncated":false,
+ "protected":false,
+ "thinkup":{
+ "retweet_count_cache":0,
+ "retweet_count_api":0,
+ "reply_count_cache":0,
+ "old_retweet_count_cache":0,
+ "is_geo_encoded":0
+ },
+ "user":{
+ "id":256559225,
+ "location":"Tordera-Barcelona",
+ "description":"Llicenciada en Ci\u00e8ncies Pol\u00edtiques i de l'Administraci\u00f3, a la Universtat Pompeu Fabra. Membre de la JNC, Deba-t i R\u00e0dio Tordera",
+ "url":"",
+ "friend_count":520,
+ "last_updated":"2012-09-03 13:23:58",
+ "followers_count":283,
+ "profile_image_url":"http://a0.twimg.com/profile_images/2169909420/ji_normal.jpg",
+ "name":"Judith",
+ "screen_name":"judithtoronjo",
+ "statuses_count":585,
+ "created_at":"Wed Feb 23 15:58:39 +0100 2011",
+ "avg_tweets_per_day":1.05,
+ "thinkup":{
+ "last_post":"0000-00-00 00:00:00",
+ "last_post_id":"",
+ "found_in":"mentions"
+ }
+ },
+ "entities":{
+ "hashtags":[
+
+ ],
+ "user_mentions":[
+ {
+ "name":"Daniel Pe\u00f1a Pizarro",
+ "id":227641758,
+ "screen_name":"penia19",
+ "indices":[
+ 0,
+ 8
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "id":242578744764690432,
+ "author_follower_count":null,
+ "source":"web",
+ "location":"Tordera-Barcelona",
+ "place":null,
+ "place_id":null,
+ "geo":null,
+ "in_reply_to_user_id":227641758,
+ "in_reply_to_post_id":242576686674223106,
+ "is_reply_by_friend":false,
+ "is_retweet_by_friend":false,
+ "reply_retweet_distance":0,
+ "in_rt_of_user_id":null,
+ "retweet_count_api":0,
+ "favlike_count_cache":0,
+ "links":[
+
+ ],
+ "favorited":false,
+ "all_retweets":0,
+ "text":"@penia19 #fcb",
+ "created_at":"Mon Sep 03 11:04:14 +0200 2012",
+ "annotations":null,
+ "truncated":false,
+ "protected":false,
+ "thinkup":{
+ "retweet_count_cache":0,
+ "retweet_count_api":0,
+ "reply_count_cache":0,
+ "old_retweet_count_cache":0,
+ "is_geo_encoded":0
+ },
+ "user":{
+ "id":256559225,
+ "location":"Tordera-Barcelona",
+ "description":"Llicenciada en Ci\u00e8ncies Pol\u00edtiques i de l'Administraci\u00f3, a la Universtat Pompeu Fabra. Membre de la JNC, Deba-t i R\u00e0dio Tordera",
+ "url":"",
+ "friend_count":520,
+ "last_updated":"2012-09-03 13:23:58",
+ "followers_count":283,
+ "profile_image_url":"http://a0.twimg.com/profile_images/2169909420/ji_normal.jpg",
+ "name":"Judith",
+ "screen_name":"judithtoronjo",
+ "statuses_count":585,
+ "created_at":"Wed Feb 23 15:58:39 +0100 2011",
+ "avg_tweets_per_day":1.05,
+ "thinkup":{
+ "last_post":"0000-00-00 00:00:00",
+ "last_post_id":"",
+ "found_in":"mentions"
+ }
+ },
+ "entities":{
+ "hashtags":[
+ {
+ "text":"fcb",
+ "indices":[
+ 9,
+ 13
+ ]
+ }
+ ],
+ "user_mentions":[
+ {
+ "name":"Daniel Pe\u00f1a Pizarro",
+ "id":227641758,
+ "screen_name":"penia19",
+ "indices":[
+ 0,
+ 8
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "id":242577856054587392,
+ "author_follower_count":null,
+ "source":"web",
+ "location":"",
+ "place":null,
+ "place_id":null,
+ "geo":null,
+ "in_reply_to_user_id":227641758,
+ "in_reply_to_post_id":242576991033888768,
+ "is_reply_by_friend":false,
+ "is_retweet_by_friend":false,
+ "reply_retweet_distance":0,
+ "in_rt_of_user_id":null,
+ "retweet_count_api":0,
+ "favlike_count_cache":0,
+ "links":[
+
+ ],
+ "favorited":false,
+ "all_retweets":0,
+ "text":"@penia19 I think he's doing great so far. #Song's contributions to the team have only just started #fcb",
+ "created_at":"Mon Sep 03 11:00:42 +0200 2012",
+ "annotations":null,
+ "truncated":false,
+ "protected":false,
+ "thinkup":{
+ "retweet_count_cache":0,
+ "retweet_count_api":0,
+ "reply_count_cache":0,
+ "old_retweet_count_cache":0,
+ "is_geo_encoded":0
+ },
+ "user":{
+ "id":45437435,
+ "location":"",
+ "description":"Powering the next Renaissance",
+ "url":"http://dani.calidos.com",
+ "friend_count":142,
+ "last_updated":"2012-09-03 13:23:59",
+ "followers_count":141,
+ "profile_image_url":"http://a0.twimg.com/profile_images/268758740/dani_normal.jpg",
+ "name":"Daniel Giribet",
+ "screen_name":"danielgiri",
+ "statuses_count":625,
+ "created_at":"Sun Jun 07 22:19:14 +0200 2009",
+ "avg_tweets_per_day":0.53,
+ "thinkup":{
+ "last_post":"0000-00-00 00:00:00",
+ "last_post_id":"",
+ "found_in":"mentions"
+ }
+ },
+ "entities":{
+ "hashtags":[
+ {
+ "text":"Song",
+ "indices":[
+ 42,
+ 47
+ ]
+ },
+ {
+ "text":"fcb",
+ "indices":[
+ 99,
+ 103
+ ]
+ }
+ ],
+ "user_mentions":[
+ {
+ "name":"Daniel Pe\u00f1a Pizarro",
+ "id":227641758,
+ "screen_name":"penia19",
+ "indices":[
+ 0,
+ 8
+ ]
+ }
+ ]
+ }
+ }
+]
View
4 docs/source/userguide/api/posts/user_posts_in_range.rst
@@ -57,7 +57,9 @@ Optional Arguments
false. This argument can be set to true by making it equal to either **1**, **t** or **true**.
.. warning::
- This is the only ThinkUp Post API method which does not enforce a cap of 200 post results returned per call.
+ The method 'user_questions_in_range', along with user_replies_in_range, post_replies_in_range,
+ user_mentions_in_range and user_posts_in_range are the ThinkUp Post API methods which do not enforce a cap of
+ 200 post results returned per call.
As such, when querying time ranges which contain more than 200 posts, keep in mind that processing that amount of
data may exceed your server's memory limits.
View
367 docs/source/userguide/api/posts/user_questions_in_range.rst
@@ -0,0 +1,367 @@
+User Questions
+==============
+Gets question posts by a user in a given time range. This will return all of the posts a user has made that contain questions in a given time range.
+
+**API call type slug:** ``user_questions_in_range``
+
+**Example Usage:** ``api/v1/post.php?type=user_questions_in_range&from=29-03-2011&until=04-04-2011&username=samwhoo``
+
+==================
+Required arguments
+==================
+
+* **user_id** or **username**
+
+ Only one of these is required. They are to specify the user to gather posts for in this call.
+
+ * **from**
+
+ The date/time to start searching from. This can either be a
+ `valid date string <http://www.php.net/manual/en/datetime.formats.php>`_ or a Unix timestamp.
+
+* **until**
+
+ The date/time to search until. This can either be a
+ `valid date string <http://www.php.net/manual/en/datetime.formats.php>`_ or a Unix timestamp.
+
+==================
+Optional Arguments
+==================
+
+* **network**
+
+ The network to use in the call. Defaults to 'twitter'.
+
+* **order_by**
+
+ The column to order the results by. Defaults to chronological order ("date").
+
+* **direction**
+
+ The direction to order the results in. Can be either DESC or ASC. Defaults to DESC.
+
+* **include_entities**
+
+ Whether or not to include `Tweet Entities <http://dev.twitter.com/pages/tweet_entities>`_ in the output. Defaults
+ to false. This argument can be set to true by making it equal to either **1**, **t** or **true**.
+
+* **include_replies**
+
+ Whether or not to include replies to this post in the output. This argument is recursive and will retrieve replies
+ to replies also. Defaults to false. This argument can be set to true by making it equal to either **1**, **t** or
+ **true**.
+
+* **trim_user**
+
+ If set to true, this flag strips the user part of the output to just the user's ID and nothing else. Defaults to
+ false. This argument can be set to true by making it equal to either **1**, **t** or **true**.
+
+.. warning::
+ The method 'user_posts_in_range', along with user_replies_in_range, post_replies_in_range,
+ user_mentions_in_range and user_questions_in_range are the ThinkUp Post API methods which do not enforce a cap of
+ 200 post results returned per call.
+ As such, when querying time ranges which contain more than 200 posts, keep in mind that processing that amount of
+ data may exceed your server's memory limits.
+
+==============
+Example output
+==============
+
+``/api/v1/post.php?type=user_questions_in_range&username=penia19&from=2012-09-03T10:50:00GMT+02:00&until=2012-09-17T017:00:00%20GMT+02:00&include_entities=t&include_replies=t``::
+
+
+[
+ {
+ "id":242576991033888768,
+ "author_follower_count":null,
+ "source":"web",
+ "location":"Alcarr\u00e0s",
+ "place":null,
+ "place_id":null,
+ "geo":null,
+ "in_reply_to_user_id":null,
+ "in_reply_to_post_id":null,
+ "is_reply_by_friend":false,
+ "is_retweet_by_friend":false,
+ "reply_retweet_distance":0,
+ "in_rt_of_user_id":null,
+ "retweet_count_api":0,
+ "favlike_count_cache":0,
+ "links":[
+
+ ],
+ "favorited":false,
+ "all_retweets":0,
+ "replies":[
+ {
+ "id":242578915867111424,
+ "author_follower_count":null,
+ "source":"web",
+ "location":"Tordera-Barcelona",
+ "place":null,
+ "place_id":null,
+ "geo":null,
+ "in_reply_to_user_id":227641758,
+ "in_reply_to_post_id":242576991033888768,
+ "is_reply_by_friend":false,
+ "is_retweet_by_friend":false,
+ "reply_retweet_distance":0,
+ "in_rt_of_user_id":null,
+ "retweet_count_api":0,
+ "favlike_count_cache":0,
+ "links":[
+
+ ],
+ "favorited":false,
+ "all_retweets":0,
+ "text":"@penia19 I don't like Alex Song",
+ "created_at":"Mon Sep 03 11:04:55 +0200 2012",
+ "annotations":null,
+ "truncated":false,
+ "protected":false,
+ "thinkup":{
+ "retweet_count_cache":0,
+ "retweet_count_api":0,
+ "reply_count_cache":0,
+ "old_retweet_count_cache":0,
+ "is_geo_encoded":0
+ },
+ "user":{
+ "id":256559225,
+ "location":"Tordera-Barcelona",
+ "description":"Llicenciada en Ci\u00e8ncies Pol\u00edtiques i de l'Administraci\u00f3, a la Universtat Pompeu Fabra. Membre de la JNC, Deba-t i R\u00e0dio Tordera",
+ "url":"",
+ "friend_count":520,
+ "last_updated":"2012-09-03 13:23:58",
+ "followers_count":283,
+ "profile_image_url":"http://a0.twimg.com/profile_images/2169909420/ji_normal.jpg",
+ "name":"Judith",
+ "screen_name":"judithtoronjo",
+ "statuses_count":585,
+ "created_at":"Wed Feb 23 15:58:39 +0100 2011",
+ "avg_tweets_per_day":1.05,
+ "thinkup":{
+ "last_post":"0000-00-00 00:00:00",
+ "last_post_id":"",
+ "found_in":"mentions"
+ }
+ },
+ "entities":{
+ "hashtags":[
+
+ ],
+ "user_mentions":[
+ {
+ "name":"Daniel Pe\u00f1a Pizarro",
+ "id":227641758,
+ "screen_name":"penia19",
+ "indices":[
+ 0,
+ 8
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "id":242577856054587392,
+ "author_follower_count":null,
+ "source":"web",
+ "location":null,
+ "place":null,
+ "place_id":null,
+ "geo":null,
+ "in_reply_to_user_id":227641758,
+ "in_reply_to_post_id":242576991033888768,
+ "is_reply_by_friend":false,
+ "is_retweet_by_friend":false,
+ "reply_retweet_distance":0,
+ "in_rt_of_user_id":null,
+ "retweet_count_api":0,
+ "favlike_count_cache":0,
+ "links":[
+
+ ],
+ "favorited":false,
+ "all_retweets":0,
+ "text":"@penia19 I think he's doing great so far. #Song's contributions to the team have only just started #fcb",
+ "created_at":"Mon Sep 03 11:00:42 +0200 2012",
+ "annotations":null,
+ "truncated":false,
+ "protected":false,
+ "thinkup":{
+ "retweet_count_cache":0,
+ "retweet_count_api":0,
+ "reply_count_cache":0,
+ "old_retweet_count_cache":0,
+ "is_geo_encoded":0
+ },
+ "user":{
+ "id":45437435,
+ "location":"",
+ "description":"Powering the next Renaissance",
+ "url":"http://dani.calidos.com",
+ "friend_count":142,
+ "last_updated":"2012-09-03 13:23:59",
+ "followers_count":141,
+ "profile_image_url":"http://a0.twimg.com/profile_images/268758740/dani_normal.jpg",
+ "name":"Daniel Giribet",
+ "screen_name":"danielgiri",
+ "statuses_count":625,
+ "created_at":"Sun Jun 07 22:19:14 +0200 2009",
+ "avg_tweets_per_day":0.53,
+ "thinkup":{
+ "last_post":"0000-00-00 00:00:00",
+ "last_post_id":"",
+ "found_in":"mentions"
+ }
+ },
+ "entities":{
+ "hashtags":[
+ {
+ "text":"Song",
+ "indices":[
+ 42,
+ 47
+ ]
+ },
+ {
+ "text":"fcb",
+ "indices":[
+ 99,
+ 103
+ ]
+ }
+ ],
+ "user_mentions":[
+ {
+ "name":"Daniel Pe\u00f1a Pizarro",
+ "id":227641758,
+ "screen_name":"penia19",
+ "indices":[
+ 0,
+ 8
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "id":242579461676101632,
+ "author_follower_count":null,
+ "source":"web",
+ "location":"Barcelona",
+ "place":null,
+ "place_id":null,
+ "geo":null,
+ "in_reply_to_user_id":227641758,
+ "in_reply_to_post_id":242576991033888768,
+ "is_reply_by_friend":false,
+ "is_retweet_by_friend":false,
+ "reply_retweet_distance":0,
+ "in_rt_of_user_id":null,
+ "retweet_count_api":0,
+ "favlike_count_cache":0,
+ "links":[
+
+ ],
+ "favorited":false,
+ "all_retweets":0,
+ "text":"@penia19 he's gonna win a lot of titles with FCB",
+ "created_at":"Mon Sep 03 11:07:05 +0200 2012",
+ "annotations":null,
+ "truncated":false,
+ "protected":false,
+ "thinkup":{
+ "retweet_count_cache":0,
+ "retweet_count_api":0,
+ "reply_count_cache":0,
+ "old_retweet_count_cache":0,
+ "is_geo_encoded":0
+ },
+ "user":{
+ "id":302708860,
+ "location":"Barcelona",
+ "description":"Research Project Manager @ TVC - I never think of the future. It comes soon enough. Albert Einstein\n",
+ "url":"http://es.linkedin.com/in/eusebiocarasusan",
+ "friend_count":247,
+ "last_updated":"2012-09-03 13:23:58",
+ "followers_count":113,
+ "profile_image_url":"http://a0.twimg.com/profile_images/2432460341/810fonvgxd8c9z65pgdi_normal.jpeg",
+ "name":"Eusebio Carasus\u00e1n",
+ "screen_name":"ecarasusan",
+ "statuses_count":417,
+ "created_at":"Sat May 21 16:40:17 +0200 2011",
+ "avg_tweets_per_day":0.89,
+ "thinkup":{
+ "last_post":"2012-08-23 17:51:19",
+ "last_post_id":"",
+ "found_in":"mentions"
+ }
+ },
+ "entities":{
+ "hashtags":[
+
+ ],
+ "user_mentions":[
+ {
+ "name":"Daniel Pe\u00f1a Pizarro",
+ "id":227641758,
+ "screen_name":"penia19",
+ "indices":[
+ 0,
+ 8
+ ]
+ }
+ ]
+ }
+ }
+ ],
+ "text":"#fcb What are your thoughts about Alex Song so far?",
+ "created_at":"Mon Sep 03 10:57:16 +0200 2012",
+ "annotations":null,
+ "truncated":false,
+ "protected":false,
+ "thinkup":{
+ "retweet_count_cache":0,
+ "retweet_count_api":0,
+ "reply_count_cache":0,
+ "old_retweet_count_cache":0,
+ "is_geo_encoded":0
+ },
+ "user":{
+ "id":227641758,
+ "location":"Alcarr\u00e0s",
+ "description":"he anat creixent...",
+ "url":"",
+ "friend_count":100,
+ "last_updated":"2012-09-03 14:43:25",
+ "followers_count":45,
+ "profile_image_url":"http://a0.twimg.com/profile_images/1830063000/IMG_0539_normal.JPG",
+ "name":"Daniel Pe\u00f1a Pizarro",
+ "screen_name":"penia19",
+ "statuses_count":91,
+ "created_at":"Fri Dec 17 11:40:19 +0100 2010",
+ "avg_tweets_per_day":0.15,
+ "thinkup":{
+ "last_post":"0000-00-00 00:00:00",
+ "last_post_id":"",
+ "found_in":"Owner Status"
+ }
+ },
+ "entities":{
+ "hashtags":[
+ {
+ "text":"fcb",
+ "indices":[
+ 0,
+ 4
+ ]
+ }
+ ],
+ "user_mentions":[
+
+ ]
+ }
+ }
+]
View
444 docs/source/userguide/api/posts/user_replies_in_range.rst
@@ -0,0 +1,444 @@
+User Replies
+============
+Gets the replies to a specific user in a given time range.
+
+**API call type slug:** ``user_replies_in_range``
+
+**Example Usage:** ``api/v1/post.php?type=user_replies_in_range&from=29-03-2011&until=04-04-2011&username=samwhoo``
+
+==================
+Required arguments
+==================
+
+* **user_id** or **username**
+
+ Only one of these is required. They are to specify the user to gather posts for in this call.
+
+* **from**
+
+ The date/time to start searching from. This can either be a
+ `valid date string <http://www.php.net/manual/en/datetime.formats.php>`_ or a Unix timestamp.
+
+* **until**
+
+ The date/time to search until. This can either be a
+ `valid date string <http://www.php.net/manual/en/datetime.formats.php>`_ or a Unix timestamp.
+
+==================
+Optional Arguments
+==================
+
+* **network**
+
+ The network to use in the call. Defaults to 'twitter'.
+
+* **order_by**
+
+ The column to order the results by. Defaults to chronological order ("date").
+
+* **direction**
+
+ The direction to order the results in. Can be either DESC or ASC. Defaults to DESC.
+
+* **include_entities**
+
+ Whether or not to include `Tweet Entities <http://dev.twitter.com/pages/tweet_entities>`_ in the output. Defaults
+ to false. This argument can be set to true by making it equal to either **1**, **t** or **true**.
+
+* **include_replies**
+
+ Whether or not to include replies to this post in the output. This argument is recursive and will retrieve replies
+ to replies also. Defaults to false. This argument can be set to true by making it equal to either **1**, **t** or
+ **true**.
+
+* **trim_user**
+
+ If set to true, this flag strips the user part of the output to just the user's ID and nothing else. Defaults to
+ false. This argument can be set to true by making it equal to either **1**, **t** or **true**.
+
+.. warning::
+ The method 'user_replies_in_range', along with user_questions_in_range, post_replies_in_range,
+ user_mentions_in_range and user_posts_in_range are the ThinkUp Post API methods which do not enforce a cap of
+ 200 post results returned per call.
+ As such, when querying time ranges which contain more than 200 posts, keep in mind that processing that amount of
+ data may exceed your server's memory limits.
+
+
+==============
+Example output
+==============
+
+``/api/v1/post.php?type=user_replies_in_range&username=penia19&from=2012-09-03T11:00:00GMT+02:00&until=2012-09-03T017:00:00%20GMT+02:00&include_entities=t&include_replies=t``::
+
+
+[
+ {
+ "id":242579576025403392,
+ "author_follower_count":null,
+ "source":"web",
+ "location":"Barcelona",
+ "place":null,
+ "place_id":null,
+ "geo":null,
+ "in_reply_to_user_id":227641758,
+ "in_reply_to_post_id":242576686674223106,
+ "is_reply_by_friend":false,
+ "is_retweet_by_friend":false,
+ "reply_retweet_distance":0,
+ "in_rt_of_user_id":null,
+ "retweet_count_api":0,
+ "favlike_count_cache":0,
+ "links":[
+
+ ],
+ "favorited":false,
+ "all_retweets":0,
+ "text":"@penia19 me too!",
+ "created_at":"Mon Sep 03 11:07:32 +0200 2012",
+ "annotations":null,
+ "truncated":false,
+ "protected":false,
+ "thinkup":{
+ "retweet_count_cache":0,
+ "retweet_count_api":0,
+ "reply_count_cache":0,
+ "old_retweet_count_cache":0,
+ "is_geo_encoded":0
+ },
+ "user":{
+ "id":302708860,
+ "location":"Barcelona",
+ "description":"Research Project Manager @ TVC - I never think of the future. It comes soon enough. Albert Einstein\n",
+ "url":"http://es.linkedin.com/in/eusebiocarasusan",
+ "friend_count":247,
+ "last_updated":"2012-09-03 13:23:58",
+ "followers_count":113,
+ "profile_image_url":"http://a0.twimg.com/profile_images/2432460341/810fonvgxd8c9z65pgdi_normal.jpeg",
+ "name":"Eusebio Carasus\u00e1n",
+ "screen_name":"ecarasusan",
+ "statuses_count":417,
+ "created_at":"Sat May 21 16:40:17 +0200 2011",
+ "avg_tweets_per_day":0.89,
+ "thinkup":{
+ "last_post":"2012-08-23 17:51:19",
+ "last_post_id":"",
+ "found_in":"mentions"
+ }
+ },
+ "entities":{
+ "hashtags":[
+
+ ],
+ "user_mentions":[
+ {
+ "name":"Daniel Pe\u00f1a Pizarro",
+ "id":227641758,
+ "screen_name":"penia19",
+ "indices":[
+ 0,
+ 8
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "id":242579461676101632,
+ "author_follower_count":null,
+ "source":"web",
+ "location":"Barcelona",
+ "place":null,
+ "place_id":null,
+ "geo":null,
+ "in_reply_to_user_id":227641758,
+ "in_reply_to_post_id":242576991033888768,
+ "is_reply_by_friend":false,
+ "is_retweet_by_friend":false,
+ "reply_retweet_distance":0,
+ "in_rt_of_user_id":null,
+ "retweet_count_api":0,
+ "favlike_count_cache":0,
+ "links":[
+
+ ],
+ "favorited":false,
+ "all_retweets":0,
+ "text":"@penia19 he's gonna win a lot of titles with FCB",
+ "created_at":"Mon Sep 03 11:07:05 +0200 2012",
+ "annotations":null,
+ "truncated":false,
+ "protected":false,
+ "thinkup":{
+ "retweet_count_cache":0,
+ "retweet_count_api":0,
+ "reply_count_cache":0,
+ "old_retweet_count_cache":0,
+ "is_geo_encoded":0
+ },
+ "user":{
+ "id":302708860,
+ "location":"Barcelona",
+ "description":"Research Project Manager @ TVC - I never think of the future. It comes soon enough. Albert Einstein\n",
+ "url":"http://es.linkedin.com/in/eusebiocarasusan",
+ "friend_count":247,
+ "last_updated":"2012-09-03 13:23:58",
+ "followers_count":113,
+ "profile_image_url":"http://a0.twimg.com/profile_images/2432460341/810fonvgxd8c9z65pgdi_normal.jpeg",
+ "name":"Eusebio Carasus\u00e1n",
+ "screen_name":"ecarasusan",
+ "statuses_count":417,
+ "created_at":"Sat May 21 16:40:17 +0200 2011",
+ "avg_tweets_per_day":0.89,
+ "thinkup":{
+ "last_post":"2012-08-23 17:51:19",
+ "last_post_id":"",
+ "found_in":"mentions"
+ }
+ },
+ "entities":{
+ "hashtags":[
+
+ ],
+ "user_mentions":[
+ {
+ "name":"Daniel Pe\u00f1a Pizarro",
+ "id":227641758,
+ "screen_name":"penia19",
+ "indices":[
+ 0,
+ 8
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "id":242578915867111424,
+ "author_follower_count":null,
+ "source":"web",
+ "location":"Tordera-Barcelona",
+ "place":null,
+ "place_id":null,
+ "geo":null,
+ "in_reply_to_user_id":227641758,
+ "in_reply_to_post_id":242576991033888768,
+ "is_reply_by_friend":false,
+ "is_retweet_by_friend":false,
+ "reply_retweet_distance":0,
+ "in_rt_of_user_id":null,
+ "retweet_count_api":0,
+ "favlike_count_cache":0,
+ "links":[
+
+ ],
+ "favorited":false,
+ "all_retweets":0,
+ "text":"@penia19 I don't like Alex Song",
+ "created_at":"Mon Sep 03 11:04:55 +0200 2012",
+ "annotations":null,
+ "truncated":false,
+ "protected":false,
+ "thinkup":{
+ "retweet_count_cache":0,
+ "retweet_count_api":0,
+ "reply_count_cache":0,
+ "old_retweet_count_cache":0,
+ "is_geo_encoded":0
+ },
+ "user":{
+ "id":256559225,
+ "location":"Tordera-Barcelona",
+ "description":"Llicenciada en Ci\u00e8ncies Pol\u00edtiques i de l'Administraci\u00f3, a la Universtat Pompeu Fabra. Membre de la JNC, Deba-t i R\u00e0dio Tordera",
+ "url":"",
+ "friend_count":520,
+ "last_updated":"2012-09-03 13:23:58",
+ "followers_count":283,
+ "profile_image_url":"http://a0.twimg.com/profile_images/2169909420/ji_normal.jpg",
+ "name":"Judith",
+ "screen_name":"judithtoronjo",
+ "statuses_count":585,
+ "created_at":"Wed Feb 23 15:58:39 +0100 2011",
+ "avg_tweets_per_day":1.05,
+ "thinkup":{
+ "last_post":"0000-00-00 00:00:00",
+ "last_post_id":"",
+ "found_in":"mentions"
+ }
+ },
+ "entities":{
+ "hashtags":[
+
+ ],
+ "user_mentions":[
+ {
+ "name":"Daniel Pe\u00f1a Pizarro",
+ "id":227641758,
+ "screen_name":"penia19",
+ "indices":[
+ 0,
+ 8
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "id":242578744764690432,
+ "author_follower_count":null,
+ "source":"web",
+ "location":"Tordera-Barcelona",
+ "place":null,
+ "place_id":null,
+ "geo":null,
+ "in_reply_to_user_id":227641758,
+ "in_reply_to_post_id":242576686674223106,
+ "is_reply_by_friend":false,
+ "is_retweet_by_friend":false,
+ "reply_retweet_distance":0,
+ "in_rt_of_user_id":null,
+ "retweet_count_api":0,
+ "favlike_count_cache":0,
+ "links":[
+
+ ],
+ "favorited":false,
+ "all_retweets":0,
+ "text":"@penia19 #fcb",
+ "created_at":"Mon Sep 03 11:04:14 +0200 2012",
+ "annotations":null,
+ "truncated":false,
+ "protected":false,
+ "thinkup":{
+ "retweet_count_cache":0,
+ "retweet_count_api":0,
+ "reply_count_cache":0,
+ "old_retweet_count_cache":0,
+ "is_geo_encoded":0
+ },
+ "user":{
+ "id":256559225,
+ "location":"Tordera-Barcelona",
+ "description":"Llicenciada en Ci\u00e8ncies Pol\u00edtiques i de l'Administraci\u00f3, a la Universtat Pompeu Fabra. Membre de la JNC, Deba-t i R\u00e0dio Tordera",
+ "url":"",
+ "friend_count":520,
+ "last_updated":"2012-09-03 13:23:58",
+ "followers_count":283,
+ "profile_image_url":"http://a0.twimg.com/profile_images/2169909420/ji_normal.jpg",
+ "name":"Judith",
+ "screen_name":"judithtoronjo",
+ "statuses_count":585,
+ "created_at":"Wed Feb 23 15:58:39 +0100 2011",
+ "avg_tweets_per_day":1.05,
+ "thinkup":{
+ "last_post":"0000-00-00 00:00:00",
+ "last_post_id":"",
+ "found_in":"mentions"
+ }
+ },
+ "entities":{
+ "hashtags":[
+ {
+ "text":"fcb",
+ "indices":[
+ 9,
+ 13
+ ]
+ }
+ ],
+ "user_mentions":[
+ {
+ "name":"Daniel Pe\u00f1a Pizarro",
+ "id":227641758,
+ "screen_name":"penia19",
+ "indices":[
+ 0,
+ 8
+ ]
+ }
+ ]
+ }
+ },
+ {
+ "id":242577856054587392,
+ "author_follower_count":null,
+ "source":"web",
+ "location":"",
+ "place":null,
+ "place_id":null,
+ "geo":null,
+ "in_reply_to_user_id":227641758,
+ "in_reply_to_post_id":242576991033888768,
+ "is_reply_by_friend":false,
+ "is_retweet_by_friend":false,
+ "reply_retweet_distance":0,
+ "in_rt_of_user_id":null,
+ "retweet_count_api":0,
+ "favlike_count_cache":0,
+ "links":[
+
+ ],
+ "favorited":false,
+ "all_retweets":0,
+ "text":"@penia19 I think he's doing great so far. #Song's contributions to the team have only just started #fcb",
+ "created_at":"Mon Sep 03 11:00:42 +0200 2012",
+ "annotations":null,
+ "truncated":false,
+ "protected":false,
+ "thinkup":{
+ "retweet_count_cache":0,
+ "retweet_count_api":0,
+ "reply_count_cache":0,
+ "old_retweet_count_cache":0,
+ "is_geo_encoded":0
+ },
+ "user":{
+ "id":45437435,
+ "location":"",
+ "description":"Powering the next Renaissance",
+ "url":"http://dani.calidos.com",
+ "friend_count":142,
+ "last_updated":"2012-09-03 13:23:59",
+ "followers_count":141,
+ "profile_image_url":"http://a0.twimg.com/profile_images/268758740/dani_normal.jpg",
+ "name":"Daniel Giribet",
+ "screen_name":"danielgiri",
+ "statuses_count":625,
+ "created_at":"Sun Jun 07 22:19:14 +0200 2009",
+ "avg_tweets_per_day":0.53,
+ "thinkup":{
+ "last_post":"0000-00-00 00:00:00",
+ "last_post_id":"",
+ "found_in":"mentions"
+ }
+ },
+ "entities":{
+ "hashtags":[
+ {
+ "text":"Song",
+ "indices":[
+ 42,
+ 47
+ ]
+ },
+ {
+ "text":"fcb",
+ "indices":[
+ 99,
+ 103
+ ]
+ }
+ ],
+ "user_mentions":[
+ {
+ "name":"Daniel Pe\u00f1a Pizarro",
+ "id":227641758,
+ "screen_name":"penia19",
+ "indices":[
+ 0,
+ 8
+ ]
+ }
+ ]
+ }
+ }
+]
View
514 tests/TestOfPostAPIController.php
@@ -1026,6 +1026,81 @@ public function testPostReplies() {
$this->assertTrue(array_search($prefix . "posts", $installer_dao->getTables()) !== false);
}
+ public function testPostRepliesInRange() {
+ $_GET['type'] = 'post_replies_in_range';
+ $_GET['post_id'] = 41;
+ $_GET['from'] = '2006-02-01 00:00:00';
+ $_GET['until'] = '2006-03-02 00:59:59';
+ $controller = new PostAPIController(true);
+ $output = json_decode($controller->go());
+
+ // test the object type is correct
+ $this->assertTrue(is_array($output));
+ foreach($output as $post) {
+ $this->assertTrue($post instanceof stdClass);
+ $this->assertEqual($post->protected, false);
+ /**
+ * The following two assertions evaluate differently depending on whether your MySQL server supports
+ * SET timezone statement in PDODAO::connect function
+ */
+ $this->assertTrue(strtotime($post->created_at) >= strtotime($_GET['from']));
+ $this->assertTrue(strtotime($post->created_at) < strtotime($_GET['until']));
+ }
+
+ $this->assertEqual(sizeof($output), 2);
+ $this->assertEqual($output[0]->id, 131);
+ $this->assertEqual($output[1]->id, 133);
+
+ // test order_by
+ $_GET['order_by'] = 'location';
+ $controller = new PostAPIController(true);
+ $output = json_decode($controller->go());
+
+ $distance = $output[0]->reply_retweet_distance;
+ foreach ($output as $post) {
+ $this->assertTrue($post->reply_retweet_distance >= $distance);
+ $distance = $post->reply_retweet_distance;
+ }
+
+ // test unit
+ $_GET['post_id'] = 41;
+ $_GET['unit'] = 'mi';
+ $controller = new PostAPIController(true);
+ $output_mi = json_decode($controller->go());
+ $_GET['unit'] = 'km';
+ $controller = new PostAPIController(true);
+ $output_km = json_decode($controller->go());
+
+ foreach ($output_km as $key=>$post) {
+ $this->assertEqual($output_mi[$key]->reply_retweet_distance,
+ round($output_km[$key]->reply_retweet_distance/1.609));
+ }
+
+ // test trim user
+ unset($_GET['count'], $_GET['page']);
+ $_GET['trim_user'] = true;
+ $controller = new PostAPIController(true);
+ $output = json_decode($controller->go());
+ $this->assertEqual(sizeof($output), 2);
+
+ foreach($output as $post) {
+ $this->assertEqual(sizeof($post->user), 1);
+ }
+
+ // test sql injection
+ $_GET = array('type' => 'post_replies');
+ $prefix = Config::getInstance()->getValue('table_prefix');
+ foreach(get_object_vars($controller) as $key => $value) {
+ if ($key == 'type' || $key == 'app_session') continue;
+ $_GET[$key] = "'; DROP TABLE " . $prefix . "posts--";
+ $controller = new PostAPIController(true);
+ $output = json_decode($controller->go());
+ unset($_GET[$key]);
+ }
+ $installer_dao = DAOFactory::getDAO('InstallerDAO');
+ $this->assertTrue(array_search($prefix . "posts", $installer_dao->getTables()) !== false);
+ }
+
public function testRelatedPosts() {
$_GET['type'] = 'related_posts';
$_GET['post_id'] = 41;
@@ -1638,6 +1713,169 @@ public function testUserMentions() {
$this->assertTrue(array_search($prefix . "posts", $installer_dao->getTables()) !== false);
}
+ public function testUserMentionsInRange() {
+ $_GET['type'] = 'user_mentions_in_range';
+ $_GET['user_id'] = 18;
+ $_GET['from'] = '2006-03-01 00:00:00';
+ $_GET['until'] = '2006-03-02 00:59:59';
+ $controller = new PostAPIController(true);
+ $output = json_decode($controller->go());
+
+ // test the object type is correct
+ $this->assertTrue(is_array($output));
+ foreach($output as $post) {
+ $this->assertTrue($post instanceof stdClass);
+ $this->assertEqual($post->protected, false);
+ /**
+ * The following two assertions evaluate differently depending on whether your MySQL server supports
+ * SET timezone statement in PDODAO::connect function
+ */
+ $this->assertTrue(strtotime($post->created_at) >= strtotime($_GET['from']));
+ $this->assertTrue(strtotime($post->created_at) < strtotime($_GET['until']));
+ }
+
+ // test order_by
+ $_GET['order_by'] = 'date';
+ $_GET['direction'] = 'DESC';
+ $controller = new PostAPIController(true);
+ $output = json_decode($controller->go());
+ $date = strtotime($output[0]->created_at);
+ foreach ($output as $post) {
+ $this->assertTrue(strtotime($post->created_at) <= $date);
+ $date = strtotime($post->created_at);
+ }
+
+ $_GET['order_by'] = 'date';
+ $_GET['direction'] = 'ASC';
+ $controller = new PostAPIController(true);
+ $output = json_decode($controller->go());
+ $date = strtotime($output[0]->created_at);
+ foreach ($output as $post) {
+ $this->assertTrue(strtotime($post->created_at) >= $date);
+ $date = strtotime($post->created_at);
+ }
+
+ $_GET['order_by'] = 'source';
+ $_GET['direction'] = 'DESC';
+ $controller = new PostAPIController(true);
+ $output = json_decode($controller->go());
+ $str = $output[0]->source;
+ foreach ($output as $post) {
+ $this->assertTrue(strcmp($post->source, $str) <= 0);
+ $str = $post->source;
+ }
+
+ $_GET['order_by'] = 'source';
+ $_GET['direction'] = 'ASC';
+ $controller = new PostAPIController(true);
+ $output = json_decode($controller->go());
+ $str = $output[0]->source;
+ foreach ($output as $post) {
+ $this->assertTrue(strcmp($post->source, $str) >= 0);
+ $str = $post->source;
+ }
+
+ $_GET['order_by'] = 'follower_count';
+ $_GET['direction'] = 'DESC';
+ $controller = new PostAPIController(true);
+ $output = json_decode($controller->go());
+ $count = $output[0]->user->followers_count;
+ foreach ($output as $post) {
+ $this->debug("Count ".$post->user->followers_count . ' <= ' . $count);
+ $this->assertTrue($post->user->followers_count <= $count);
+ $count = $post->user->followers_count;
+ }
+
+ $_GET['order_by'] = 'follower_count';
+ $_GET['direction'] = 'ASC';
+ $controller = new PostAPIController(true);
+ $output = json_decode($controller->go());
+ $count = $output[0]->user->followers_count;
+ foreach ($output as $post) {
+ $this->debug($post->id . " - Count ".$post->user->followers_count . ' >= ' . $count);
+ $this->assertTrue($post->user->followers_count >= $count);
+ $count = $post->user->followers_count;
+ }
+
+ $_GET['order_by'] = 'post_text';
+ $_GET['direction'] = 'DESC';
+ $controller = new PostAPIController(true);
+ $output = json_decode($controller->go());
+ $str = $output[0]->text;
+ foreach ($output as $post) {
+ $this->assertTrue(strcmp($post->text, $str) <= 0);
+ $str = $post->text;
+ }
+
+ $_GET['order_by'] = 'post_text';
+ $_GET['direction'] = 'ASC';
+ $controller = new PostAPIController(true);
+ $output = json_decode($controller->go());
+ $str = $output[0]->text;
+ foreach ($output as $post) {
+ $this->assertTrue(strcmp($post->text, $str) >= 0);
+ $str = $post->text;
+ }
+
+ $_GET['order_by'] = 'author_username';
+ $_GET['direction'] = 'DESC';
+ $controller = new PostAPIController(true);
+ $output = json_decode($controller->go());
+ $str = $output[0]->user->screen_name;
+ foreach ($output as $post) {
+ $this->assertTrue(strcmp($post->user->screen_name, $str) <= 0);
+ $str = $post->user->screen_name;
+ }
+
+ $_GET['order_by'] = 'author_username';
+ $_GET['direction'] = 'ASC';
+ $controller = new PostAPIController(true);
+ $output = json_decode($controller->go());
+ $str = $output[0]->user->screen_name;
+ foreach ($output as $post) {
+ $this->assertTrue(strcmp($post->user->screen_name, $str) >= 0);
+ $str = $post->user->screen_name;
+ }
+
+ // test tweet entities
+ $_GET['include_entities'] = true;
+ $controller = new PostAPIController(true);
+ $output = json_decode($controller->go());
+ $this->assertEqual(sizeof($output), 2);
+
+ // test trim user
+ unset($_GET['include_entities']);
+ $_GET['trim_user'] = true;
+ $controller = new PostAPIController(true);
+ $output = json_decode($controller->go());
+ $this->assertEqual(sizeof($output), 2);
+ $this->assertEqual(sizeof($output[0]->user), 1);
+
+ // test sql injection
+ $_GET = array('type' => 'user_mentions_in_range');
+ $prefix = Config::getInstance()->getValue('table_prefix');
+ foreach(get_object_vars($controller) as $key => $value) {
+ if ($key == 'type' || $key == 'app_session') continue;
+ $_GET[$key] = "'; DROP TABLE " . $prefix . "posts--";
+ $controller = new PostAPIController(true);
+ $output = json_decode($controller->go());
+ unset($_GET[$key]);
+ }
+ $installer_dao = DAOFactory::getDAO('InstallerDAO');
+ $this->assertTrue(array_search($prefix . "posts", $installer_dao->getTables()) !== false);
+
+ // test posts contain a links object
+ $_GET['type'] = 'user_mentions_in_range';
+ $_GET['user_id'] = 18;
+ $_GET['from'] = '2006-03-01 00:01:00';
+ $_GET['until'] = '2006-03-01 00:23:01';
+ $controller = new PostAPIController(true);
+ $output = json_decode($controller->go());
+ foreach($output as $post) {
+ $this->assertTrue($post->links instanceof stdClass);
+ }
+ }
+
public function testUserMentionsProtectedOnNetwork() {
$_GET['type'] = 'user_mentions';
$_GET['user_id'] = 24;
@@ -1845,6 +2083,145 @@ public function testUserRepliesProtectedInThinkUp() {
$this->assertEqual($output->error->message, "The requested user data is not available.");
}
+ public function testUserRepliesInRange() {
+ $_GET['type'] = 'user_replies_in_range';
+ $_GET['user_id'] = 18;
+ $_GET['from'] = '2006-02-01 00:00:00';
+ $_GET['until'] = '2006-03-02 00:59:59';
+ $controller = new PostAPIController(true);
+ $output = json_decode($controller->go());
+ // test the object type is correct
+ $this->assertTrue(is_array($output));
+ foreach($output as $post) {
+ $this->assertTrue($post instanceof stdClass);
+ $this->assertEqual($post->protected, false);
+ $this->assertEqual($post->in_reply_to_user_id, 18);
+ /**
+ * The following two assertions evaluate differently depending on whether your MySQL server supports
+ * SET timezone statement in PDODAO::connect function
+ */
+ $this->assertTrue(strtotime($post->created_at) >= strtotime($_GET['from']));
+ $this->assertTrue(strtotime($post->created_at) < strtotime($_GET['until']));
+ }
+
+ $this->assertEqual(sizeof($output), 2);
+
+ // test order_by
+ $_GET['order_by'] = 'date';
+ $_GET['direction'] = 'DESC';
+ $controller = new PostAPIController(true);
+ $output = json_decode($controller->go());
+ $date = strtotime($output[0]->created_at);
+ foreach ($output as $post) {
+ $this->assertTrue(strtotime($post->created_at) <= $date);
+ $date = strtotime($post->created_at);
+ }
+
+ $_GET['order_by'] = 'date';
+ $_GET['direction'] = 'ASC';
+ $controller = new PostAPIController(true);
+ $output = json_decode($controller->go());
+ $date = strtotime($output[0]->created_at);
+ foreach ($output as $post) {
+ $this->assertTrue(strtotime($post->created_at) >= $date);
+ $date = strtotime($post->created_at);
+ }
+
+ $_GET['order_by'] = 'source';
+ $_GET['direction'] = 'DESC';
+ $controller = new PostAPIController(true);
+ $output = json_decode($controller->go());
+ $str = $output[0]->source;
+ foreach ($output as $post) {
+ $this->assertTrue(strcmp($post->source, $str) <= 0);
+ $str = $post->source;
+ }
+
+ $_GET['order_by'] = 'source';
+ $_GET['direction'] = 'ASC';
+ $controller = new PostAPIController(true);
+ $output = json_decode($controller->go());
+ $str = $output[0]->source;
+ foreach ($output as $post) {
+ $this->assertTrue(strcmp($post->source, $str) >= 0);
+ $str = $post->source;
+ }
+
+ $_GET['order_by'] = 'follower_count';
+ $_GET['direction'] = 'DESC';
+ $controller = new PostAPIController(true);
+ $output = json_decode($controller->go());
+ $count = $output[0]->user->followers_count;
+ foreach ($output as $post) {
+ $this->debug("Count ".$post->user->followers_count);
+ $this->assertTrue($post->user->followers_count <= $count);
+ $count = $post->user->followers_count;
+ }
+
+ $_GET['order_by'] = 'follower_count';
+ $_GET['direction'] = 'ASC';
+ $controller = new PostAPIController(true);
+ $output = json_decode($controller->go());
+ $count = $output[0]->user->followers_count;
+ foreach ($output as $post) {
+ $this->assertTrue($post->user->followers_count >= $count);
+ $count = $post->user->followers_count;
+ }
+
+ $_GET['order_by'] = 'post_text';
+ $_GET['direction'] = 'DESC';
+ $controller = new PostAPIController(true);
+ $output = json_decode($controller->go());
+ $str = $output[0]->text;
+ foreach ($output as $post) {
+ $this->assertTrue(strcmp($post->text, $str) <= 0);
+ $str = $post->text;
+ }
+
+ $_GET['order_by'] = 'post_text';
+ $_GET['direction'] = 'ASC';
+ $controller = new PostAPIController(true);
+ $output = json_decode($controller->go());
+ $str = $output[0]->text;
+ foreach ($output as $post) {
+ $this->assertTrue(strcmp($post->text, $str) >= 0);
+ $str = $post->text;
+ }
+
+ $_GET['order_by'] = 'author_username';
+ $_GET['direction'] = 'DESC';
+ $controller = new PostAPIController(true);
+ $output = json_decode($controller->go());
+ $str = $output[0]->user->screen_name;
+ foreach ($output as $post) {
+ $this->assertTrue(strcmp($post->user->screen_name, $str) <= 0);
+ $str = $post->user->screen_name;
+ }
+
+ $_GET['order_by'] = 'author_username';
+ $_GET['direction'] = 'ASC';
+ $controller = new PostAPIController(true);
+ $output = json_decode($controller->go());
+ $str = $output[0]->user->screen_name;
+ foreach ($output as $post) {
+ $this->assertTrue(strcmp($post->user->screen_name, $str) >= 0);
+ $str = $post->user->screen_name;
+ }
+
+ // test sql injection
+ $_GET = array('type' => 'user_replies');
+ $prefix = Config::getInstance()->getValue('table_prefix');
+ foreach(get_object_vars($controller) as $key => $value) {
+ if ($key == 'type' || $key == 'app_session') continue;
+ $_GET[$key] = "'; DROP TABLE " . $prefix . "posts--";
+ $controller = new PostAPIController(true);
+ $output = json_decode($controller->go());
+ unset($_GET[$key]);
+ }
+ $installer_dao = DAOFactory::getDAO('InstallerDAO');
+ $this->assertTrue(array_search($prefix . "posts", $installer_dao->getTables()) !== false);
+ }
+
public function testUserQuestions() {
$_GET['type'] = 'user_questions';
$_GET['user_id'] = 20;
@@ -2001,6 +2378,143 @@ public function testUserQuestions() {
$this->assertTrue(array_search($prefix . "posts", $installer_dao->getTables()) !== false);
}
+ public function testUserQuestionsInRange() {
+ $_GET['type'] = 'user_questions_in_range';
+ $_GET['user_id'] = 20;
+ $_GET['from'] = '2006-03-01 00:00:00';
+ $_GET['until'] = '2006-03-02 00:59:59';
+ $controller = new PostAPIController(true);
+ $output = json_decode($controller->go());
+
+ // test the object type is correct
+ $this->assertTrue(is_array($output));
+ foreach($output as $post) {
+ $this->assertTrue($post instanceof stdClass);
+ $this->assertEqual($post->protected, false);
+ $this->assertEqual(preg_match('/\?/', $post->text), 1);
+ /**
+ * The following two assertions evaluate differently depending on whether your MySQL server supports
+ * SET timezone statement in PDODAO::connect function
+ */
+ $this->assertTrue(strtotime($post->created_at) >= strtotime($_GET['from']));
+ $this->assertTrue(strtotime($post->created_at) < strtotime($_GET['until']));
+ }
+
+ // test order_by
+ $_GET['order_by'] = 'date';
+ $_GET['direction'] = 'DESC';
+ $controller = new PostAPIController(true);
+ $output = json_decode($controller->go());
+ $date = strtotime($output[0]->created_at);
+ foreach ($output as $post) {
+ $this->assertTrue(strtotime($post->created_at) <= $date);
+ $date = strtotime($post->created_at);
+ }
+
+ $_GET['order_by'] = 'date';
+ $_GET['direction'] = 'ASC';
+ $controller = new PostAPIController(true);
+ $output = json_decode($controller->go());
+ $date = strtotime($output[0]->created_at);
+ foreach ($output as $post) {
+ $this->assertTrue(strtotime($post->created_at) >= $date);
+ $date = strtotime($post->created_at);
+ }
+
+ $_GET['order_by'] = 'source';
+ $_GET['direction'] = 'DESC';
+ $controller = new PostAPIController(true);
+ $output = json_decode($controller->go());
+ $str = $output[0]->source;
+ foreach ($output as $post) {
+ $this->assertTrue(strcmp($post->source, $str) <= 0);
+ $str = $post->source;
+ }
+
+ $_GET['order_by'] = 'source';
+ $_GET['direction'] = 'ASC';
+ $controller = new PostAPIController(true);
+ $output = json_decode($controller->go());
+ $str = $output[0]->source;
+ foreach ($output as $post) {
+ $this->assertTrue(strcmp($post->source, $str) >= 0);
+ $str = $post->source;
+ }
+
+ $_GET['order_by'] = 'follower_count';
+ $_GET['direction'] = 'DESC';
+ $controller = new PostAPIController(true);
+ $output = json_decode($controller->go());
+ $count = $output[0]->user->followers_count;
+ foreach ($output as $post) {
+ $this->assertTrue($post->user->followers_count <= $count);
+ $count = $post->user->followers_count;
+ }
+
+ $_GET['order_by'] = 'follower_count';
+ $_GET['direction'] = 'ASC';
+ $controller = new PostAPIController(true);
+ $output = json_decode($controller->go());
+ $count = $output[0]->user->followers_count;
+ foreach ($output as $post) {
+ $this->assertTrue($post->user->followers_count >= $count);
+ $count = $post->user->followers_count;
+ }
+
+ $_GET['order_by'] = 'post_text';
+ $_GET['direction'] = 'DESC';
+ $controller = new PostAPIController(true);
+ $output = json_decode($controller->go());
+ $str = $output[0]->text;
+ foreach ($output as $post) {
+ $this->assertTrue(strcmp($post->text, $str) <= 0);
+ $str = $post->text;
+ }
+
+ $_GET['order_by'] = 'post_text';
+ $_GET['direction'] = 'ASC';
+ $controller = new PostAPIController(true);
+ $output = json_decode($controller->go());
+ $str = $output[0]->text;
+ foreach ($output as $post) {
+ $this->assertTrue(strcmp($post->text, $str) >= 0);
+ $str = $post->text;
+ }
+
+ $_GET['order_by'] = 'author_username';
+ $_GET['direction'] = 'DESC';
+ $controller = new PostAPIController(true);
+ $output = json_decode($controller->go());
+ $str = $output[0]->user->screen_name;
+ foreach ($output as $post) {
+ $this->assertTrue(strcmp($post->user->screen_name, $str) <= 0);
+ $str = $post->user->screen_name;
+ }
+
+ $_GET['order_by'] = 'author_username';
+ $_GET['direction'] = 'ASC';
+ $controller = new PostAPIController(true);
+ $output = json_decode($controller->go());
+ $str = $output[0]->user->screen_name;
+ foreach ($output as $post) {
+ $this->assertTrue(strcmp($post->user->screen_name, $str) >= 0);
+ $str = $post->user->screen_name;
+ }
+
+ // test sql injection
+ $_GET = array('type' => 'user_questions');
+ $prefix = Config::getInstance()->getValue('table_prefix');
+ foreach(get_object_vars($controller) as $key => $value) {
+ if ($key == 'type' || $key == 'app_session') continue;
+ $_GET[$key] = "'; DROP TABLE " . $prefix . "posts--";
+ $controller = new PostAPIController(true);
+ $output = json_decode($controller->go());
+ unset($_GET[$key]);
+ }
+ $installer_dao = DAOFactory::getDAO('InstallerDAO');
+ $this->assertTrue(array_search($prefix . "posts", $installer_dao->getTables()) !== false);
+ }
+
public function testUserQuestionsProtectedOnNetwork() {
$_GET['type'] = 'user_questions';
$_GET['user_id'] = 24;
View
218 tests/TestOfPostMySQLDAO.php
@@ -192,8 +192,7 @@ protected function buildData() {
'author_username'=>'user_123456', 'author_fullname'=>'User 123456', 'is_geo_encoded'=>0,
'old_retweet_count_cache' => 0, 'in_rt_of_user_id' => null, 'is_protected'=>1,
'post_text'=>'This is link post '.$counter, 'source'=>'web', 'pub_date'=>'2006-03-01 00:'.
- $pseudo_minute.':00', 'reply_count_cache'=>0, 'retweet_count_cache'=>0, 'network'=>'twitter',
- 'in_reply_to_user_id'=>''));
+ $pseudo_minute.':00', 'reply_count_cache'=>0, 'retweet_count_cache'=>0, 'network'=>'twitter'));
$counter++;
}
@@ -215,7 +214,7 @@ protected function buildData() {
$builders[] = FixtureBuilder::build('posts', array('id'=>133, 'post_id'=>133, 'author_user_id'=>19,
'author_username'=>'linkbaiter', 'author_fullname'=>'Link Baiter', 'network'=>'twitter',
'post_text'=>'@shutterbug This is a link post reply http://example.com/', 'source'=>'web',
- 'pub_date'=>'2006-03-01 00:00:00', 'reply_count_cache'=>0, 'retweet_count_cache'=>0,
+ 'pub_date'=>'2006-03-03 00:00:00', 'reply_count_cache'=>0, 'retweet_count_cache'=>0,
'old_retweet_count_cache' => 0, 'in_rt_of_user_id' => null, 'is_protected'=>0,
'in_reply_to_post_id'=>41, 'location'=>'Mumbai, Maharashtra, India', 'reply_retweet_distance'=>1500,
'is_geo_encoded'=>1));
@@ -420,6 +419,78 @@ public function testGetAllQuestionPosts() {
$this->assertEqual($questions[0]->post_text,
'I need a new cell phone. Not this http://bit.ly/blah or this http://bit.ly/blah2 What should I buy?');
}
+
+ /**
+ * Test getAllQuestionPostosInRange
+ */
+ public function testgetAllQuestionPostsInRange() {
+ $builders = array();
+ //Add a question
+ $post_builder = FixtureBuilder::build('posts', array('author_user_id'=>'13', 'author_username'=>'ev',
+ 'post_text'=>'I need a new cell phone. Not this http://bit.ly/blah or this http://bit.ly/blah2 '.
+ 'What should I buy?', 'network'=>'twitter', 'in_reply_to_post_id'=>0,
+ 'pub_date'=>'2006-02-01 00:05:00'));
+
+ array_push($builders, $post_builder);
+ $post_key = $post_builder->columns['last_insert_id'];
+
+ $builders[] = FixtureBuilder::build('links', array('post_key'=>$post_key, 'url'=>'http://bit.ly/blah'));
+ $builders[] = FixtureBuilder::build('links', array('post_key'=>$post_key, 'url'=>'http://bit.ly/blah2'));
+
+ $dao = new PostMySQLDAO();
+ $questions = $dao->getAllQuestionPostsInRange('13', 'twitter', '10', $from = '2006-02-01 00:04:00',
+ $until= '2006-02-02 00:10:00');
+
+ $this->debug('Questions: ' . $questions);
+
+ $this->assertEqual(sizeof($questions), 1);
+ $this->assertEqual($questions[0]->post_text,
+ 'I need a new cell phone. Not this http://bit.ly/blah or this http://bit.ly/blah2 What should I buy?' );
+ $this->assertEqual(sizeof($questions[0]->links), 2 );
+ $this->assertEqual($questions[0]->links[0]->url, 'http://bit.ly/blah' );
+ $this->assertEqual($questions[0]->links[1]->url, 'http://bit.ly/blah2' );
+
+ //Add another question
+ $builder[] = FixtureBuilder::build('posts', array('author_user_id'=>13, 'author_username'=>'ev',
+ 'post_text'=>'Best sushi in NY? downtown', 'network'=>'twitter', 'in_reply_to_post_id'=>0,
+ 'pub_date'=>'2006-02-01 00:06:00'));
+
+ $questions = $dao->getAllQuestionPostsInRange('13', 'twitter', '10', $from = '2006-02-01 00:04:00',
+ $until= '2006-02-01 00:10:00');
+ $this->assertEqual(sizeof($questions), 2);
+ $this->assertEqual($questions[0]->post_text, 'Best sushi in NY? downtown' );
+ $this->assertEqual($questions[1]->post_text,
+ 'I need a new cell phone. Not this http://bit.ly/blah or this http://bit.ly/blah2 What should I buy?' );
+
+ //Messages with a question mark in between two characters (e.g. URLs) aren't necessarily questions
+