в html
Код: Выделить всё
function wallpost(){ VK.init(function(){ VK.api("photos.getWallUploadServer", {uid:viewer_id}, function(data){ $.post('upload.php', {upload_url:data.response.upload_url}, function(input){ VK.api("photos.saveWallPhoto", {server:input.server, photo:input.photo, hash:input.hash, uid:viewer_id}, function(data){ VK.api("wall.post", {owner_id:data.response[0].owner_id, message:"Blabla", attachments:data.response[0].id}); pinPhoto = data.response[0].id; }); },'json') }) }) }
Код: Выделить всё
<?php if (isset($_POST["upload_url"])) {define('BASEPATH', str_replace('\\', '/', dirname(__FILE__)) . '/'); $upload_url = $_POST["upload_url"]; $post_params['photo'] = '@'.BASEPATH."1.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); $result = json_decode($result); $mess = array ('server' => $result->server, 'photo' => $result->photo, 'hash' => $result->hash); echo json_encode($mess); }?>
PS. Я только учусь не ругайтесь!