Код: Выделить всё
<!DOCTYPE html><html><head><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script><script src="http://vkontakte.ru/js/api/openapi.js?49" type="text/javascript"></script> <script type="text/javascript">VK.init({apiId: 3012101, onlyWidgets: true});VK.Auth.login(function (response) { VK.Api.call('photos.getWallUploadServer', {}, function (r) {alert ( JSON.stringify( r ) );$.post('upload.php', {url: r.response.upload_url}, function(data){ var mas = data.split(';');var photo = mas[1].split('"'); //photo[3]var p = photo[3];var hash1 = mas[2];alert(hash1);var serv = mas[0];VK.Api.call('photos.saveWallPhoto', {server: serv, hash: hash1, photo: p}, function (d) { }); }); });//photoupload}, VK.access.PHOTO ); </script> </body></html>
Код: Выделить всё
<?php if (isset($_POST["url"])) { $upload_url = $_POST["url"]; $post_params['photo'] = '@'.'0.png'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $upload_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_params); $result = curl_exec($ch); curl_close($ch); //var_dump($result); $result = json_decode($result); $mess = array (server => $result->server, photo=> $result->photo, hash => $result->hash); echo "$mess[server];$mess[photo];$result->hash"; }?>