GOAL:
My goal is to get the total number of likes and comments of the last 3 posts of an Instagram account, and assign them to separate variables.
ISSUE:
I am able to call the total likes and comments of the latest post only, I am not sure how to call for the other posts information. I have been trying for hours.
LOGICAL EXPLANATION OF GOAL:
$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;
CURRENT CODE:
$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;
LINK TO DATA:
I am a PHP newbie and would appreciate your help! Thank you