Answer the question
In order to leave comments, you need to log in
Working with an array from VKontakte api, how to get photo and audio?
Hello.
Guys, tell me, please, how to work with an array that gives VKontakte when requested.
I make a request
$result = json_decode(file_get_contents('https://api.vk.com/method/wall.getById?'. $get_params));
$result -> response[0] -> text;
$result -> response[0] -> copy_history[0] -> attachments[0] -> photo;
object(stdClass)#1 (1) {
["response"]=>
array(1) {
[0]=>
object(stdClass)#2 (10) {
["id"]=>
int(3804)
["from_id"]=>
int(90161593)
["owner_id"]=>
int(90161593)
["date"]=>
int(1469004331)
["post_type"]=>
string(4) "post"
["text"]=>
string(0) ""
["copy_history"]=>
array(1) {
[0]=>
object(stdClass)#3 (8) {
["id"]=>
int(110778)
["owner_id"]=>
int(-46347604)
["from_id"]=>
int(-46347604)
["date"]=>
int(1468999805)
["post_type"]=>
string(4) "post"
["text"]=>
string(665) "Аудиокнига «Психология влияния» - Р.Чалдини
"В этой книге Роберт Чалдини, доктор наук, профессор психологии и признанный эксперт в сфере влияния и убеждения, рассматривает шесть универсальных приемов, благодаря которым вы станете настоящим мастером уговоров. В то же время, зная об этих приемах, вы всегда сможете избежать нежелательного воздействия со стороны.""
["attachments"]=>
array(10) {
[0]=>
object(stdClass)#4 (2) {
["type"]=>
string(5) "photo"
["photo"]=>
object(stdClass)#5 (13) {
["id"]=>
int(422898685)
["album_id"]=>
int(-7)
["owner_id"]=>
int(-46347604)
["user_id"]=>
int(100)
["photo_75"]=>
string(50) "http://cs7002.vk.me/v7002028/1f8f9/Q5Ky-U5eWa0.jpg"
["photo_130"]=>
string(50) "http://cs7002.vk.me/v7002028/1f8fa/_ch9S6xrr9g.jpg"
["photo_604"]=>
string(50) "http://cs7002.vk.me/v7002028/1f8fb/WtioodnFjZ8.jpg"
["width"]=>
int(470)
["height"]=>
int(600)
["text"]=>
string(0) ""
["date"]=>
int(1468999804)
["post_id"]=>
int(110778)
["access_key"]=>
string(18) "18a1e10557a69906af"
}
}
[1]=>
object(stdClass)#6 (2) {
["type"]=>
string(5) "audio"
["audio"]=>
object(stdClass)#7 (8) {
["id"]=>
int(382665174)
["owner_id"]=>
int(2000148619)
["artist"]=>
string(65) "Роберт Чалдини - Психология влияния"
["title"]=>
string(41) "Глава 1. Орудия влияния"
["duration"]=>
int(4002)
["date"]=>
int(1437303323)
["url"]=>
string(183) "http://cs1-37v4.vk-cdn.net/p9/973e9bb850388d.mp3?extra=3FVfPJqxC7efhviZGhUEpVdbetHgkCHgANU6-vCeClHiVWYP9u4wwWCccrJfTwoi6FsaOQ1e287nZ4m2ofXkmM-qjyrEvmUhh0Yp_57UY_UJeuoF-kngyoYGXQTTX7ME"
["album_id"]=>
int(2)
}
}
[2]=>
object(stdClass)#8 (2) {
["type"]=>
string(5) "audio"
["audio"]=>
object(stdClass)#9 (8) {
["id"]=>
int(456239453)
["owner_id"]=>
int(2000372708)
["artist"]=>
string(66) "Роберт Чалдини - Психология влияния"
["title"]=>
string(30) "2. Взаимный обмен"
["duration"]=>
int(4848)
["date"]=>
int(1468999805)
["url"]=>
string(183) "http://cs1-50v4.vk-cdn.net/p6/6b106b730523ce.mp3?extra=M1e_R9FgA3bN0_V5GCCuLtN7GQS9mABv-xvXYje1VKKzgn0bI1bHVPl6BFqQqyexKtJoJq8PnyZmaM0A8oMVOG0iTD6mBg69ASziYzkwpnFCtF3qcA0PJ1TN4XkBPjW5"
["genre_id"]=>
int(1001)
}
}
[3]=>
object(stdClass)#10 (2) {
["type"]=>
string(5) "audio"
["audio"]=>
object(stdClass)#11 (8) {
["id"]=>
int(456239452)
["owner_id"]=>
int(2000372827)
["artist"]=>
string(66) "Роберт Чалдини - Психология влияния"
["title"]=>
string(71) "3. Обязательство и последовательность-1"
["duration"]=>
int(4849)
["date"]=>
int(1468999805)
["url"]=>
тут я обрезал, одно и тоже
}
}
}
}
Answer the question
In order to leave comments, you need to log in
Add ->photo_604 . Variants of numbers corresponding to the size of the photo are in the documentation. With the comparison of numbers, I think you can handle it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question