diff --git a/csshttprequest.php b/csshttprequest.php index edf0a7f..9fe6724 100644 --- a/csshttprequest.php +++ b/csshttprequest.php @@ -23,7 +23,8 @@ function encode($string) { /* unit test */ if(STDIN) { - echo encode(fgets(STDIN)); + $string = file_get_contents("php://stdin", "r"); + echo encode($string); } ?> diff --git a/tests/json-flickr.in b/tests/json-flickr.in new file mode 100644 index 0000000..90e4604 --- /dev/null +++ b/tests/json-flickr.in @@ -0,0 +1,229 @@ +{ + "title": "Recent Uploads tagged favorite", + "link": "http://www.flickr.com/photos/tags/favorite/", + "description": "", + "modified": "2008-12-23T01:39:21Z", + "generator": "http://www.flickr.com/", + "items": [ + { + "title": "nyhavn", + "link": "http://www.flickr.com/photos/mcm/3129802228/", + "media": {"m":"http://farm4.static.flickr.com/3130/3129802228_4509c87972_m.jpg"}, + "date_taken": "2008-12-05T22:13:31-08:00", + "description": "
mcmCPH<\/a> posted a photo:<\/p> <\/a><\/p> ",
+ "published": "2008-12-23T01:39:21Z",
+ "author": "nobody@flickr.com (mcmCPH)",
+ "author_id": "47341069@N00",
+ "tags": "favorite copenhagen denmark nyhavn"
+ },
+ {
+ "title": "denmark - me and malcolm ice skating in copenhagen",
+ "link": "http://www.flickr.com/photos/mcm/3129782702/",
+ "media": {"m":"http://farm4.static.flickr.com/3229/3129782702_4da69b2b74_m.jpg"},
+ "date_taken": "2008-09-29T11:31:29-08:00",
+ "description": " mcmCPH<\/a> posted a photo:<\/p> <\/a><\/p> ",
+ "published": "2008-12-23T01:29:55Z",
+ "author": "nobody@flickr.com (mcmCPH)",
+ "author_id": "47341069@N00",
+ "tags": "favorite copenhagen denmark michael malcolm frederiksberg"
+ },
+ {
+ "title": "farewells2007",
+ "link": "http://www.flickr.com/photos/mcm/3128878401/",
+ "media": {"m":"http://farm4.static.flickr.com/3205/3128878401_bcdd01d3c7_m.jpg"},
+ "date_taken": "2008-12-05T22:15:17-08:00",
+ "description": " mcmCPH<\/a> posted a photo:<\/p> <\/a><\/p> a collage of farewells from when we left DK, July 2007<\/p>",
+ "published": "2008-12-23T00:52:17Z",
+ "author": "nobody@flickr.com (mcmCPH)",
+ "author_id": "47341069@N00",
+ "tags": "friends favorite denmark"
+ },
+ {
+ "title": "Choices.",
+ "link": "http://www.flickr.com/photos/marvelous_nature/3129615474/",
+ "media": {"m":"http://farm4.static.flickr.com/3120/3129615474_d9f7a3d892_m.jpg"},
+ "date_taken": "2008-12-22T17:04:41-08:00",
+ "description": " marvelous_nature<\/a> posted a photo:<\/p> <\/a><\/p> "Buddy the Elf! What\'s your favorite color?" mcmCPH<\/a> posted a photo:<\/p> <\/a><\/p> ",
+ "published": "2008-12-22T23:42:38Z",
+ "author": "nobody@flickr.com (mcmCPH)",
+ "author_id": "47341069@N00",
+ "tags": "favorite denmark malcolm susan christiania børnehave birkerød"
+ },
+ {
+ "title": "Panorama desde la Alberca Caesar\'s",
+ "link": "http://www.flickr.com/photos/rafachapa/3128676265/",
+ "media": {"m":"http://farm4.static.flickr.com/3206/3128676265_c413958e81_m.jpg"},
+ "date_taken": "2008-10-29T08:49:24-08:00",
+ "description": " rafachapa<\/a> posted a photo:<\/p> <\/a><\/p> ",
+ "published": "2008-12-22T23:08:47Z",
+ "author": "nobody@flickr.com (rafachapa)",
+ "author_id": "8960796@N03",
+ "tags": "trees panorama sculpture horse favorite usa water caballo hotel agua américa arboles lasvegas nevada esculturas nv strip animales caesarspalace 2008 estadosunidos eeuu"
+ },
+ {
+ "title": "Panorama Lobby Caesar\'s de Noche - 2",
+ "link": "http://www.flickr.com/photos/rafachapa/3129463284/",
+ "media": {"m":"http://farm4.static.flickr.com/3262/3129463284_e707c40218_m.jpg"},
+ "date_taken": "2008-10-28T23:16:57-08:00",
+ "description": " rafachapa<\/a> posted a photo:<\/p> <\/a><\/p> ",
+ "published": "2008-12-22T22:48:06Z",
+ "author": "nobody@flickr.com (rafachapa)",
+ "author_id": "8960796@N03",
+ "tags": "wallpaper panorama sculpture favorite usa detalle detail restaurant hotel américa lasvegas nevada decoration esculturas nv strip caesarspalace fountains 2008 fuentes slotmachine estadosunidos onearmbandit eeuu decoración maquinitas tragamonedas"
+ },
+ {
+ "title": "Panorama Venetian Mirage 08",
+ "link": "http://www.flickr.com/photos/rafachapa/3129455268/",
+ "media": {"m":"http://farm4.static.flickr.com/3198/3129455268_276c8bcfee_m.jpg"},
+ "date_taken": "2008-10-28T22:07:31-08:00",
+ "description": " rafachapa<\/a> posted a photo:<\/p> <\/a><\/p> ",
+ "published": "2008-12-22T22:44:38Z",
+ "author": "nobody@flickr.com (rafachapa)",
+ "author_id": "8960796@N03",
+ "tags": "longexposure trees wallpaper panorama favorite usa night ads hotel noche américa arboles lasvegas nevada movimiento nv strip mirage 2008 thebeatles estadosunidos anuncios thevenetian eeuu largaexposición"
+ },
+ {
+ "title": "The Strip at Night",
+ "link": "http://www.flickr.com/photos/rafachapa/3128614027/",
+ "media": {"m":"http://farm4.static.flickr.com/3133/3128614027_b725fb3f1f_m.jpg"},
+ "date_taken": "2008-09-15T23:15:30-08:00",
+ "description": " rafachapa<\/a> posted a photo:<\/p> <\/a><\/p> ",
+ "published": "2008-12-22T22:39:34Z",
+ "author": "nobody@flickr.com (rafachapa)",
+ "author_id": "8960796@N03",
+ "tags": "wallpaper favorite usa water night ads hotel noche agua américa lasvegas nevada nv strip bellagio fountains planethollywood ballys 2008 citycenter fuentes parislasvegas estadosunidos anuncios eeuu"
+ },
+ {
+ "title": "Path to Wynn",
+ "link": "http://www.flickr.com/photos/rafachapa/3128552637/",
+ "media": {"m":"http://farm4.static.flickr.com/3292/3128552637_c52084a68a_m.jpg"},
+ "date_taken": "2008-09-15T16:37:38-08:00",
+ "description": " rafachapa<\/a> posted a photo:<\/p> <\/a><\/p> ",
+ "published": "2008-12-22T22:12:02Z",
+ "author": "nobody@flickr.com (rafachapa)",
+ "author_id": "8960796@N03",
+ "tags": "trees wallpaper favorite usa ads hotel américa arboles treasureisland lasvegas nevada nv strip wynn 2008 encore estadosunidos anuncios fashionshowmall eeuu favorito"
+ },
+ {
+ "title": "X-MAS FAVE",
+ "link": "http://www.flickr.com/photos/mundoperfeito/3129365080/",
+ "media": {"m":"http://farm4.static.flickr.com/3252/3129365080_1e36a7c459_m.jpg"},
+ "date_taken": "2008-12-22T20:04:03-08:00",
+ "description": " MundoPerfeito<\/a> posted a photo:<\/p> <\/a><\/p> 1. Merry X-Mas!<\/a>, 2. Cupcakes<\/a>, 3. wishing on a star.<\/a>, 4. *muse*<\/a>, 5. Untitled<\/a>, 6. Untitled<\/a>, 7. snowflakes<\/a>, 8. bokeh berries<\/a>, 9. Untitled<\/a>, 10. untold stories<\/a>, 11. i see christmas bokeh everywhere...<\/a>, 12. Xmas Birds<\/a>, 13. Reaching for a star 2008!<\/a>, 14. Anjos<\/a>, 15. Sangue di Dionisio<\/a>, 16. self-portrait on a christmas ball<\/a> rafachapa<\/a> posted a photo:<\/p> <\/a><\/p> ",
+ "published": "2008-12-22T22:00:54Z",
+ "author": "nobody@flickr.com (rafachapa)",
+ "author_id": "8960796@N03",
+ "tags": "trees wallpaper favorite usa water ads hotel agua américa arboles treasureisland lasvegas nevada nv strip wynn 2008 estadosunidos anuncios eeuu"
+ },
+ {
+ "title": "Wynn and Encore from the Bay - 2",
+ "link": "http://www.flickr.com/photos/rafachapa/3129353258/",
+ "media": {"m":"http://farm4.static.flickr.com/3178/3129353258_e3171fa245_m.jpg"},
+ "date_taken": "2008-09-15T16:34:37-08:00",
+ "description": " rafachapa<\/a> posted a photo:<\/p> <\/a><\/p> ",
+ "published": "2008-12-22T21:58:49Z",
+ "author": "nobody@flickr.com (rafachapa)",
+ "author_id": "8960796@N03",
+ "tags": "trees wallpaper favorite usa water ads hotel agua américa arboles treasureisland lasvegas nevada nv strip wynn 2008 estadosunidos anuncios eeuu"
+ },
+ {
+ "title": "Net Worth",
+ "link": "http://www.flickr.com/photos/rafachapa/3129347366/",
+ "media": {"m":"http://farm4.static.flickr.com/3230/3129347366_6eaafd1a4e_m.jpg"},
+ "date_taken": "2008-09-15T16:33:48-08:00",
+ "description": " rafachapa<\/a> posted a photo:<\/p> <\/a><\/p> ",
+ "published": "2008-12-22T21:56:17Z",
+ "author": "nobody@flickr.com (rafachapa)",
+ "author_id": "8960796@N03",
+ "tags": "trees wallpaper favorite usa detalle detail water hotel agua américa arboles treasureisland lasvegas nevada nv strip wynn 2008 estadosunidos thevenetian eeuu"
+ },
+ {
+ "title": "Pirate Boat - 1",
+ "link": "http://www.flickr.com/photos/rafachapa/3129334974/",
+ "media": {"m":"http://farm4.static.flickr.com/3263/3129334974_d72be7a466_m.jpg"},
+ "date_taken": "2008-09-15T16:32:24-08:00",
+ "description": " rafachapa<\/a> posted a photo:<\/p> <\/a><\/p> ",
+ "published": "2008-12-22T21:50:55Z",
+ "author": "nobody@flickr.com (rafachapa)",
+ "author_id": "8960796@N03",
+ "tags": "trees favorite usa water hotel boat agua américa arboles treasureisland lasvegas nevada nv strip wynn 2008 bote estadosunidos eeuu"
+ },
+ {
+ "title": "Caesar\'s Choice - 4",
+ "link": "http://www.flickr.com/photos/rafachapa/3128489659/",
+ "media": {"m":"http://farm4.static.flickr.com/3266/3128489659_b5f68d0011_m.jpg"},
+ "date_taken": "2008-09-15T12:34:57-08:00",
+ "description": " rafachapa<\/a> posted a photo:<\/p> <\/a><\/p> ",
+ "published": "2008-12-22T21:43:13Z",
+ "author": "nobody@flickr.com (rafachapa)",
+ "author_id": "8960796@N03",
+ "tags": "sculpture favorite usa ads hotel américa lasvegas nevada esculturas nv strip caesarspalace ballys 2008 parislasvegas estadosunidos anuncios eeuu construcciones"
+ },
+ {
+ "title": "Wynn and Encore from the Bay - 1",
+ "link": "http://www.flickr.com/photos/rafachapa/3129329092/",
+ "media": {"m":"http://farm4.static.flickr.com/3207/3129329092_3f7f2e81f9_m.jpg"},
+ "date_taken": "2008-09-15T16:32:07-08:00",
+ "description": " rafachapa<\/a> posted a photo:<\/p> <\/a><\/p> ",
+ "published": "2008-12-22T21:48:07Z",
+ "author": "nobody@flickr.com (rafachapa)",
+ "author_id": "8960796@N03",
+ "tags": "trees wallpaper favorite usa water hotel boat store agua américa arboles treasureisland lasvegas nevada nv tienda strip wynn 2008 bote estadosunidos eeuu favorito"
+ },
+ {
+ "title": "Independencia de México - 1",
+ "link": "http://www.flickr.com/photos/rafachapa/3128472897/",
+ "media": {"m":"http://farm4.static.flickr.com/3128/3128472897_d068b57ee5_m.jpg"},
+ "date_taken": "2008-09-15T12:32:19-08:00",
+ "description": " rafachapa<\/a> posted a photo:<\/p> <\/a><\/p> ",
+ "published": "2008-12-22T21:35:40Z",
+ "author": "nobody@flickr.com (rafachapa)",
+ "author_id": "8960796@N03",
+ "tags": "trees wallpaper sculpture favorite usa detalle detail water ads hotel agua américa arboles lasvegas nevada esculturas nv strip carro caesarspalace fountains 2008 fuentes estadosunidos anuncios eeuu construcciones favorito"
+ },
+ {
+ "title": "Shadow at Caesar\'s Palace - 1",
+ "link": "http://www.flickr.com/photos/rafachapa/3128462155/",
+ "media": {"m":"http://farm4.static.flickr.com/3079/3128462155_7fffba38a2_m.jpg"},
+ "date_taken": "2008-09-15T12:12:00-08:00",
+ "description": " rafachapa<\/a> posted a photo:<\/p> <\/a><\/p> ",
+ "published": "2008-12-22T21:30:50Z",
+ "author": "nobody@flickr.com (rafachapa)",
+ "author_id": "8960796@N03",
+ "tags": "wallpaper favorite usa bar ads restaurant hotel américa shadows lasvegas nevada nv strip caesarspalace 2008 sombras unfocus estadosunidos anuncios desenfocada eeuu"
+ },
+ {
+ "title": "By the Pool - 1",
+ "link": "http://www.flickr.com/photos/rafachapa/3128423615/",
+ "media": {"m":"http://farm4.static.flickr.com/3228/3128423615_05d9edb75d_m.jpg"},
+ "date_taken": "2008-09-15T12:00:10-08:00",
+ "description": "
Choose one! :)<\/p>",
+ "published": "2008-12-23T00:04:41Z",
+ "author": "nobody@flickr.com (marvelous_nature)",
+ "author_id": "27243539@N06",
+ "tags": "favorite color green thread sewing shades choices"
+ },
+ {
+ "title": "denmark - first day at bornehave on christiania - susan and malcolm",
+ "link": "http://www.flickr.com/photos/mcm/3128743785/",
+ "media": {"m":"http://farm4.static.flickr.com/3255/3128743785_281a363c36_m.jpg"},
+ "date_taken": "2008-12-22T15:42:38-08:00",
+ "description": "
Created with fd\'s Flickr Toys<\/a>.<\/p>",
+ "published": "2008-12-22T22:04:03Z",
+ "author": "nobody@flickr.com (MundoPerfeito)",
+ "author_id": "56153257@N00",
+ "tags": "favorite fdsflickrtoys mosaic mosaico faves favoritos"
+ },
+ {
+ "title": "Wynn and Encore from the Bay - 3",
+ "link": "http://www.flickr.com/photos/rafachapa/3128528607/",
+ "media": {"m":"http://farm4.static.flickr.com/3091/3128528607_50633094ba_m.jpg"},
+ "date_taken": "2008-09-15T16:35:00-08:00",
+ "description": "