Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. onWallPost = async () => {
  2.         const {imageData, selectedName} = this.props;
  3.         const token = (VKConnect.default.send("VKWebAppGetAuthToken", {
  4.             "app_id": 7022091,
  5.             "scope": "photos"
  6.         })).then((token) => {
  7.             token = token.data;
  8.             if (token.scope !== 'photos') return;
  9.             let url = (VKConnect.default.send("VKWebAppCallAPIMethod", {
  10.                 method: 'photos.getWallUploadServer',
  11.                 params: {
  12.                     access_token: token.access_token,
  13.                     v: '5.95'
  14.                 }
  15.             })
  16.                 .then(async (url) => {
  17.                     const {photo, server, hash} = (await (await fetch('https://toystory-backend.wnm.digital/share/wall', {
  18.                         method: 'POST',
  19.                         headers: {
  20.                             'Content-Type': 'application/json'
  21.                         },
  22.                         body: JSON.stringify({
  23.                             params,
  24.                             server: url.data.response.upload_url,
  25.                             name: selectedName,
  26.                             file: imageData
  27.                         })
  28.                     })).json()).resp
  29.                     console.log('Code before here is ok')
  30.                     const saved = (VKConnect.default.send("VKWebAppCallApiMethod", {
  31.                         method: "photos.saveWallPhoto",
  32.                         params: {
  33.                             access_token: token.access_token,
  34.                             v: '5.9',
  35.                             //photo, server, hash
  36.                         }
  37.                     }).then((saved) => {
  38.                         console.log('Code after here is not happening anywhere')
  39.                         console.log(saved);
  40.                         connect.send("VKWebAppShowWallPostBox", {
  41.                             "message": "Hello!",
  42.                             attachments: `photo${saved[0].owner_id}_${saved[0].id}`
  43.                         }).catch((e) => {
  44.                             console.error(e);
  45.                         });
  46.                     }).catch((e) => {
  47.                         console.error(e);
  48.                     }))
  49.                 })
  50.                 .catch((e) => {
  51.                     console.error(e);
  52.                 }))
  53.         })
  54.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement