I
I
Ivan Zhivolupov2015-02-23 15:59:09
PHP
Ivan Zhivolupov, 2015-02-23 15:59:09

VK audio.get and invalid url, solution?

Hello, I decided to make a small web application for listening to music from VK (after deleting Audio Recordings from iOS), as a result, the player successfully receives all the records, successfully receives the Artist, Title, Cover (via iTunes), but completely refuses to play the track.
I understand that the fact is that the user logged in with IP 123.234.123.234 (example)
and the server has IP 234.123.234.123 (example), therefore, after binding the record to IP, the VK server can no longer give the record to the user, but gives it to the server itself . Therefore, my question is, how can you play music from the user by making a request from the server?
By the way, here is the image with the result (in the console, a direct request for the same URL from the server) (The picture is clickable, taken from Habrastorage)
3dcc3a9b0342489b91debf8dafa5f4a3.PNG
The backend is PHP, therefore all requests go through it + OAuth2.0
Here is a link to localhost:
https://cs1-31v4.vk-cdn.net/p8/7aa9ddecd985e9.mp3 - Everything works, you can listen (the request is from one IP )
And here is the link from the server:
https://psv6.vk.me/c4510/u58711694/audios/a45df583... - The server can listen (via RDP), but the user from the browser will receive an error, they say the page does not exist
Is there any solutions to this problem, or was it done on purpose in order to prohibit this kind of listening to music?
PS I read on stackoverflow that you can try to set CURLOPT_HTTPHEADER like

CURLOPT_HTTPHEADER => array("REMOTE_ADDR: ".$_SERVER['REMOTE_ADDR'], "HTTP_X_FORWARDED_FOR: ".$_SERVER['REMOTE_ADDR'])

but it didn't help, still 404 page if requested from the server and opened in the browser
If you need any clarifications on the code, I'm always here

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Filatov, 2015-02-23
@wendel

There are 2 options for solving your problem:
1. Use Javascript API to get the mp3 URL, then the link will be bound to the client's IP and not the server's.
2. If you do not want to use the Javascript API, make a repeater script that will pass the received URL to a PHP script, which in turn will read the file from the contact and give it to the user, i.e. instead of the URL issued by the API backend, send the player a URL like /play.php?vk =link that came from api, play.php gets the link, reads the file and gives it to the user.
Fake ip will not work, you don’t even have to try, it’s checked.

N
Nazar Mokrinsky, 2015-02-24
@nazarpc

There is a third option - to raise an SSH tunnel to the server or VPN on it (which is a little more difficult) and go out into the world from under the same IP as the server)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question