Answer the question
In order to leave comments, you need to log in
Why does vk api return empty "photo":"[]" ???
<?php
if (!isset($_GET['url']))
exit();
$url = $_GET['url'];
$img_src = $_FILES["photo"]["tmp_name"];
$img_str = curl_file_create($img_src);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_URL, $url);
$data_str = array(
'photo' => $img_str,
'file1' => $img_str
);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_str);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: multipart/form-data'));
$result = curl_exec($ch);
curl_close($ch);
header('Access-Control-Allow-Origin: *');
header('Content-Type: application/json');
echo $result;
?>
Answer the question
In order to leave comments, you need to log in
$img_src = '4.png';
$post_params = array(
'file1' => '@'.$img_src,
);
file_get_contents('https://api.vk.com/method/photos.getWallUploadServ...'.$access_token);
$dataArray=json_decode($data);
$ch = curl_init( $dataArray->response->upload_url );
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_params);
$response = curl_exec( $ch );
curl_close( $ch );
print_r($response);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question