Permalink
Browse files

add repost test cases;

1 parent 98c474e commit 7e036e8b7a940d397d7b587948ed3196974614d6 @fengmk2 fengmk2 committed May 26, 2012
Showing with 819 additions and 864 deletions.
  1. +2 −0 .gitignore
  2. +5 −0 .npmignore
  3. +24 −16 README.md
  4. 0 { → examples}/testMiddleWare.js
  5. +1 −1 index.js
  6. +9 −8 lib/oauth.js
  7. +3 −3 lib/sha1.js
  8. +59 −41 lib/tapi.js
  9. +561 −537 lib/tsina.js
  10. +21 −63 lib/utils.js
  11. +0 −1 start-test.sh
  12. +0 −93 test.js
  13. +2 −2 test/base64.js
  14. +8 −7 test/config.js
  15. +0 −49 test/tapi.test.js
  16. +59 −2 test/{tapi.js → tsina.js}
  17. +65 −2 test/utils.js
  18. +0 −39 weibo.js
View
@@ -1,3 +1,5 @@
.project
.settings
node_modules/
+lib-cov
+coverage.html
View
@@ -4,3 +4,8 @@ support/
.settings/
.project
mkdoc.sh
+Makefile
+gtap
+node_modules
+.travis.yml
+coverage.html
View
@@ -30,44 +30,52 @@ $ npm install weibo
## How to use
-### Browser
+### Browser: `Phonegap` or `Chrome extension`
-```javascript
-// Include the `weibo.js` javascript files:
+* require `jQuery`
-<script type="text/javascript" src="/weibo/weibo.js"></script>
+```javascript
+// Include the javascript files:
+
+<script src="lib/weibo/lib/eventproxy.js"></script>
+<script src="lib/weibo/lib/base64.js"></script>
+<script src="lib/weibo/lib/sha1.js"></script>
+<script src="lib/weibo/lib/utils.js"></script>
+<script src="lib/weibo/lib/oauth.js"></script>
+<script src="lib/weibo/lib/urllib.js"></script>
+<script src="lib/weibo/lib/tsina.js"></script>
+<script src="lib/weibo/lib/tapi.js"></script>
<script type="text/javascript">
-// load all the lib scripts with urlprefix where the `weibo` directory you put into
-weibo.load('/weibo/');
-
var tapi = weibo.TAPI;
var appkey = 'your appkey', secret = 'your app secret';
var oauth_callback_url = 'your callback url' || 'oob';
tapi.init('tsina', appkey, secret, oauth_callback_url);
-tapi.public_timeline({}, function (error, data, xhr) {
- if (error) {
+tapi.public_timeline({ user: { blogType: 'tsina' } }, function (err, statuses) {
+ if (err) {
console.error(error);
} else {
- console.log(data);
+ console.log(statuses);
}
});
-
</script>
```
### Server
```javascript
-var tapi = require('weibo').tapi;
+
+var tapi = require('weibo');
+
// change appkey to yours
var appkey = 'your appkey', secret = 'your app secret';
var oauth_callback_url = 'your callback url' || 'oob';
tapi.init('tsina', appkey, secret, oauth_callback_url);
-tapi.public_timeline({}, function (error, data, response) {
- if (error) {
- console.error(error);
+
+tapi.public_timeline({ user: { blogType: 'tsina' } }, function (err, statuses) {
+ if (err) {
+ console.error(err);
} else {
- console.log(data);
+ console.log(statuses);
}
});
```
File renamed without changes.
View
@@ -8,5 +8,5 @@
* Module dependencies.
*/
-var libpath = process.env.URLLIB_COV ? './lib-cov' : './lib';
+var libpath = process.env.WEIBO_COV ? './lib-cov' : './lib';
module.exports = require(libpath + '/tapi');
View
@@ -168,17 +168,17 @@ OAuth.setProperties(OAuth, {
var parameters = message.parameters;
if (parameters instanceof Array) {
for (var p = 0; p < parameters.length; ++p) {
- if (parameters[p][0] === name) {
- if (value === undefined) {
- parameters.splice(p, 1);
- } else {
- parameters[p][1] = value;
- value = undefined;
- }
+ if (parameters[p][0] === name) {
+ if (value === undefined) {
+ parameters.splice(p, 1);
+ } else {
+ parameters[p][1] = value;
+ value = undefined;
}
+ }
}
if (value !== undefined) {
- parameters.push([name, value]);
+ parameters.push([name, value]);
}
} else {
parameters = OAuth.getParameterMap(parameters);
@@ -273,6 +273,7 @@ OAuth.setProperties(OAuth.SignatureMethod.prototype, {
sign: function sign(message) {
var baseString = OAuth.SignatureMethod.getBaseString(message);
var signature = this.getSignature(baseString);
+ // console.log(baseString, this.key, signature)
OAuth.setParameter(message, "oauth_signature", signature);
return signature; // just in case someone's interested
},
View
@@ -32,17 +32,17 @@ var chrsz = 8; /* bits per input character. 8 - ASCII; 16 - Unicode */
* They take string arguments and return either hex or base-64 encoded strings
*/
function hex_sha1(s) {
- return binb2hex(core_sha1(str2binb(s),s.length * chrsz));
+ return binb2hex(core_sha1(str2binb(s), s.length * chrsz));
}
exports.hex_sha1 = hex_sha1;
function b64_sha1(s) {
- return binb2b64(core_sha1(str2binb(s),s.length * chrsz));
+ return binb2b64(core_sha1(str2binb(s), s.length * chrsz));
}
exports.b64_sha1 = b64_sha1;
function str_sha1(s) {
- return binb2str(core_sha1(str2binb(s),s.length * chrsz));
+ return binb2str(core_sha1(str2binb(s), s.length * chrsz));
}
exports.str_sha1 = str_sha1;
Oops, something went wrong. Retry.

0 comments on commit 7e036e8

Please sign in to comment.