PageRenderTime 51ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/php/tools/test.php

http://blipapi.googlecode.com/
PHP | 174 lines | 34 code | 30 blank | 110 comment | 3 complexity | baa6f24585baa9f6fbefb167ffa39da0 MD5 | raw file
  1. <?php
  2. /**
  3. * Blip! (http://blip.pl) communication library.
  4. *
  5. * Simple testing utility
  6. *
  7. * @author Marcin Sztolcman <marcin /at/ urzenia /dot/ net>
  8. * @version 0.02.32
  9. * @version $Id: blipapi.php 136 2010-01-06 18:00:54Z urzenia $
  10. * @copyright Copyright (c) 2007, Marcin Sztolcman
  11. * @license http://opensource.org/licenses/lgpl-3.0.html The GNU Lesser General Public License, version 3.0 (LGPLv3)
  12. * @package blipapi_tools
  13. */
  14. define ('ROOT', dirname (dirname (__FILE__)));
  15. include ROOT.'/lib/blipapi.php';
  16. include ROOT.'/tools/lib.php';
  17. require_once ROOT.'/lib/OAuth.php';
  18. import_const ();
  19. $oauth_consumer = new OAuthConsumer (CONSUMER_KEY, CONSUMER_SECRET);
  20. $oauth_token = new OAuthToken (TOKEN_KEY, TOKEN_SECRET);
  21. function test () {
  22. $args = func_get_args ();
  23. $type = array_shift ($args);
  24. $action = array_shift ($args);
  25. $type = 'BlipApi_' . ucfirst (strtolower ($type));
  26. $c = new $type ();
  27. $i_max = count ($args);
  28. for ($i=0; $i<$i_max; $i+=2) {
  29. $key = $args[$i];
  30. $c->$key = $args[$i+1];
  31. }
  32. if (isset ($_ENV['SERVER_ADDR'])) {
  33. echo '<pre>';
  34. }
  35. print_r ($GLOBALS['b']->$action ($c));
  36. if (isset ($_ENV['SERVER_ADDR'])) {
  37. echo '</pre>';
  38. }
  39. }
  40. $b = new BlipApi ($oauth_consumer, $oauth_token);
  41. $b->timeout = 0;
  42. # $b = new BlipApi ();
  43. $b->debug = true;
  44. $i1 = '/Users/mysz/ROZNE/avatar.jpg';
  45. $i2 = '/Users/mysz/test_img/test_jpg/01.jpg';
  46. $t = strftime ('%Y%m%d %H%M%S', time ());
  47. ## Avatar
  48. # test ('avatar', 'update', 'image', $i1);
  49. # test ('avatar', 'read', 'user', 'mysz');
  50. # test ('avatar', 'read', 'user', 'dupa', 'url_only', 1);
  51. # test ('avatar', 'read', 'user', 'dupa', 'url_only', 1, 'size', 'femto');
  52. # test ('avatar', 'read', 'user', 'dupa', 'url_only', 1, 'size', 'a');
  53. # test ('avatar', 'delete');
  54. ## Background
  55. # test ('background', 'read', 'user', 'myszapi');
  56. # test ('background', 'update', 'image', $i1);
  57. # test ('background', 'delete');
  58. ## Bliposphere
  59. # test ('bliposphere', 'read', 'since_id', 49072082);
  60. # test ('bliposphere', 'read', 'limit', 2);
  61. # test ('bliposphere', 'read', 'limit', 2, 'include', array ('user', 'user[avatar]'));
  62. ## Dashboard
  63. # test ('dashboard', 'read');
  64. # test ('dashboard', 'read', 'limit', 2, 'user', 'opi');
  65. # test ('dashboard', 'read', 'limit', 2, 'include', array ('user', 'user[avatar]'));
  66. ## Dirmsg
  67. # test ('dirmsg', 'create', 'body', 'qwe ' . $t, 'user', 'myszapi');
  68. # test ('dirmsg', 'create', 'body', 'qwe ' . $t, 'user', 'myszapi', 'image', $i2);
  69. # test ('dirmsg', 'read', 'id', 31482231);
  70. # test ('dirmsg', 'read', 'user', 'myszapi', 'limit', 2);
  71. # test ('dirmsg', 'read', 'user', 'myszapi', 'limit', 2, 'include', array ('user', 'user[avatar]'));
  72. # test ('dirmsg', 'read', 'user', 'myszapi', 'limit', 2, 'include', array ('user', 'user[avatar]'), 'offset', 1);
  73. # test ('dirmsg', 'read', 'since_id', 31482231, 'limit', 10);
  74. # test ('dirmsg', 'delete', 'id', 31482231);
  75. #
  76. ## Movie
  77. # test ('movie', 'read', 'id', 8337417);
  78. ## Notice
  79. # test ('notice', 'read', 'user', 'myszapi', 'limit', 2);
  80. # test ('notice', 'read', 'user', 'myszapi', 'limit', 2, 'offset', 1);
  81. # test ('notice', 'read', 'user', 'myszapi', 'limit', 2, 'offset', 1, 'include', array ('user', 'user[avatar]'));
  82. ## Picture
  83. # test ('picture', 'read', 'id', 8336732);
  84. # test ('picture', 'read', 'id', 8336732, 'include', array ('update'));
  85. # test ('picture', 'read', 'limit', 2);
  86. # test ('picture', 'read', 'limit', 2, 'include', array ('update'));
  87. ## Privmsg
  88. # test ('privmsg', 'create', 'body', 'qwe ' . $t, 'user', 'myszapi');
  89. # test ('privmsg', 'create', 'body', 'qwe ' . $t, 'user', 'myszapi', 'image', $i2);
  90. # test ('privmsg', 'read', 'id', 31531016);
  91. # test ('privmsg', 'read', 'limit', 2);
  92. # test ('privmsg', 'read', 'limit', 2, 'include', array ('user', 'user[avatar]'));
  93. # test ('privmsg', 'read', 'limit', 2, 'include', array ('user', 'user[avatar]'), 'offset', 1);
  94. # test ('privmsg', 'delete', 'id', 31531016);
  95. ## Recording
  96. # test ('recording', 'read', 'id', 26884443);
  97. ## Shortlink
  98. # test ('shortlink', 'create', 'link', 'http://asd.qwe.urzenia.net');
  99. # test ('shortlink', 'read', 'code', '371co');
  100. # test ('shortlink', 'read', 'limit', 2);
  101. # test ('shortlink', 'read', 'since_id', 4803669, 'limit', 3);
  102. ## Status
  103. # test ('status', 'create', 'body', 'qwe ' . $t);
  104. # test ('status', 'create', 'body', 'qwe ' . $t, 'image', $i2);
  105. # test ('status', 'read', 'id', 43045534);
  106. # test ('status', 'read', 'user', 'opi', 'limit', 2);
  107. # test ('status', 'read', 'user', 'myszapi', 'limit', 2, 'include', array ('user', 'user[avatar]'));
  108. # test ('status', 'read', 'user', 'myszapi', 'limit', 2, 'include', array ('user', 'user[avatar]'), 'offset', 1);
  109. # test ('status', 'delete', 'id', 31393068);
  110. ## Subscription
  111. # test ('subscription', 'read', 'direction', 'to');
  112. # test ('subscription', 'read', 'direction', 'from');
  113. # test ('subscription', 'read', 'direction', 'to', 'include', array ('tracking_user', 'tracking_user[current_status]'));
  114. # test ('subscription', 'update', 'user', 'mysz', 'www', true);
  115. # test ('subscription', 'update', 'user', 'mysz', 'www', false);
  116. # test ('subscription', 'delete', 'user', 'mysz');
  117. # test ('tagsub', 'read');
  118. # test ('tagsub', 'read', 'type', 'ignore');
  119. # test ('tagsub', 'read', 'type', 'ignore', 'include', array ('user', 'tag'));
  120. # test ('tagsub', 'read', 'include', array ('user', 'tag'));
  121. # test ('tagsub', 'create', 'name', 'panoponkateam');
  122. # test ('tagsub', 'create', 'name', 'panoponkateam^&'); # ma sie wyrznac! niewlasciwa nazwa taga
  123. # test ('tagsub', 'create', 'name', 'panoponkateam', 'type', 'ignore');
  124. # test ('tagsub', 'delete', 'name', 'panoponkateam');
  125. ## Tag
  126. # test ('tag', 'read', 'tag', 'wpblip');
  127. # test ('tag', 'read', 'tag', 'wpblip', 'limit', 3);
  128. # test ('tag', 'read', 'tag', 'wpblip', 'limit', 3, 'include', 'user');
  129. # test ('tag', 'read', 'tag', 'foto', 'limit', 3, 'include', array ('user', 'pictures'));
  130. ## Update
  131. # test ('update', 'create', 'body', 'qwe ' . $t);
  132. # test ('update', 'create', 'body', 'qwe ' . $t, 'user', 'myszapi', 'image', $i2);
  133. # test ('update', 'create', 'body', 'qwe ' . $t, 'user', 'myszapi', 'image', $i2, 'private', true);
  134. # test ('update', 'read', 'id', 31552664);
  135. # test ('update', 'read', 'user', 'opi', 'limit', 2);
  136. # test ('update', 'read', 'user', 'myszapi', 'limit', 2, 'include', array ('user', 'user[avatar]'));
  137. # test ('update', 'delete', 'id', 31543467);
  138. ## Update Search
  139. # test ('updateSearch', 'read');
  140. # test ('updateSearch', 'read', 'query', 'myszfoto');
  141. test ('updateSearch', 'read', 'query', 'swype');
  142. ## User
  143. # test ('user', 'read');
  144. # test ('user', 'read', 'include', array ('current_status', 'avatar'));