第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用 PHP 調(diào)用公共 Instagram JSON 數(shù)據(jù)并將它們分配給變量

使用 PHP 調(diào)用公共 Instagram JSON 數(shù)據(jù)并將它們分配給變量

PHP
素胚勾勒不出你 2021-06-30 13:04:05
目標(biāo):我的目標(biāo)是獲取 Instagram 帳戶最后 3 個帖子的喜歡和評論總數(shù),并將它們分配給單獨(dú)的變量。問題:我只能調(diào)用最新帖子的總贊和評論,我不確定如何調(diào)用其他帖子信息。我已經(jīng)嘗試了幾個小時。目標(biāo)的邏輯解釋:$post1_likes = number of likes from post;$post1_comments = number of comments from post;$post2_likes = number of likes from post;$post2_comments = number of comments from post;$post3_likes = number of likes from post;$post3_comments = number of comments from post;$combine_all = $post1_likes + $post1_comments + $post2_likes + $post2_comments $post3_likes + $post3_comments;return combine_all;當(dāng)前代碼:$raw = file_get_contents('https://www.instagram.com/instagram');preg_match('/\"edge_media_preview_like\"\:\s?\{\"count\"\:\s?([0-9]+)/',$raw,$m1);preg_match('/\"edge_media_to_comment\"\:\s?\{\"count\"\:\s?([0-9]+)/',$raw,$m2);$combine_all = $m2[1] + $m1[1];return $combine_all;
查看完整描述

2 回答

?
紫衣仙女

TA貢獻(xiàn)1839條經(jīng)驗(yàn) 獲得超15個贊

在您獲取信息之前,您閱讀的 JSON 具有相當(dāng)多的數(shù)據(jù)層。下面的代碼應(yīng)該讓你開始了解你需要做什么......


// Decode the data to a nested associative array

$json = json_decode($raw, true);


// Loop through each of the edges

foreach ( $json['graphql']['user']['edge_felix_video_timeline']['edges'] as $edge ){

    echo $edge['node']['edge_media_to_comment']['count'].'/'

        .$edge['node']['edge_media_preview_like']['count'].PHP_EOL;

}


查看完整回答
反對 回復(fù) 2021-07-09
  • 2 回答
  • 0 關(guān)注
  • 209 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號