Advertisement
Guest User

Untitled

a guest
Dec 15th, 2017
420
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. /**
  2. * @header
  3. * @name MyCred API call
  4. * @description Integrate with MyCred
  5. * @category Custom APIs
  6. */
  7.  
  8. /**
  9. * @inspectable
  10. * @name Transition
  11. * @description Where this block transitions when it is finished
  12. * @type transition
  13. */
  14. const transition = `57410cd5-9b2c-499a-a3f8-1962ffabffb4`;
  15.  
  16.  
  17. const secretKey = 'HIDDEN';
  18. const remoteUrl = 'HIDDEN';
  19.  
  20. const action = 'CREDIT';
  21. const account = 'HIDDEN@HIDDEN.edu';
  22. const amount = 10;
  23. const ref = 'metaverse';
  24. //const refId = 0;
  25. const entry = 'Points for completing a Metaverse Experience!';
  26. //const data = 'optional extra';
  27. const pointType = 'mycred_default';
  28.  
  29. const host = 'https://www.gonmeta.io';
  30.  
  31. // Calculate token
  32.  
  33.  
  34.  
  35. let token = `${host}${action}${amount}${secretKey}`;
  36. token = await Meta.actions.post(`http://api.rest7.com/v1/text_hash.php?text=${token}&algo=md5`, { method: 'get' });
  37. token = await token.json();
  38. token = JSON.stringify(token);
  39. token = token.hash;
  40.  
  41. Meta.actions.post(remoteUrl, {
  42. method: 'POST',
  43. headers: {
  44. Accept: 'application/x-www-form-urlencoded',
  45. 'Content-Type': 'application/x-www-form-urlencoded',
  46. },
  47. //body: `action=${action}&account=${account}&amount=${amount}&ref=${ref}&ref_id=${refId}&type=${pointType}&entry=${entry}&data=${data}&host=${host}&token=${token}`,
  48. body: `action=${action}&account=${account}&amount=${amount}&ref=${ref}&type=${pointType}&entry=${entry}&host=${host}&token=${token}`,
  49. });
  50.  
  51. Meta.callbacks.transitionTo(transition);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement