Advertisement
KiberInfinity

vk upload photo by url

Jan 15th, 2013
235
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function vkURLUploadPhoto(url){
  2.    if (!url) url=prompt('Image URL');
  3.    AjGet('http://vk.com/wall'+vk.id+'?offset=100000000',function(r,t){
  4.       var o=(t.match(/"share":(\{[^}]+\})/)||[])[1];
  5.       if (!o) {alert('hash error'); return;}
  6.       o=eval('('+o+')');
  7.       //alert(o.timehash);
  8.       re(ge('vk_url_upldr_form'));
  9.       checkURLForm = ce('div', {url:'vk_url_upldr_form', innerHTML: '<iframe name="vk_url_upldr_form_iframe"></iframe>'});
  10.       utilsNode.appendChild(checkURLForm);
  11.       var parseForm = checkURLForm.appendChild(ce('form', {
  12.         action: 'share.php?act=url_attachment',
  13.         method: 'post',
  14.         target: 'vk_url_upldr_form_iframe'
  15.       }));
  16.      
  17.       each({hash: o.timehash || '', index: 1, url: url}, function(i, v) {
  18.         parseForm.appendChild(ce('input', {type: 'hidden', name: i, value: v}));
  19.       });
  20.      
  21.       window.onUploadDone = function(data){
  22.          showPhoto(data[1],data[2].list,{});
  23.          console.log(data);
  24.       }
  25.       window.onUploadFail = function(){alert('Upload Fail')}
  26.  
  27.       parseForm.submit();
  28.    })
  29. }
  30. vkURLUploadPhoto('http://savepic.ru/3860219.png');
Advertisement
RAW Paste Data Copied
Advertisement