How to get a user's Instagram feed

后端 未结 7 885
北海茫月
北海茫月 2020-12-04 23:10

I\'d like to get a user\'s Instagram feed using PHP. I\'ve signed up for an Instagram Developer Account and tried pulling in a user\'s info and photos, but the response isn

7条回答
  •  独厮守ぢ
    2020-12-04 23:48

    try this one a crawler type in raw form.

    function feed_instagram($url = "https://www.instagram.com/titaniumheart_")
    {  
        //$url ie https://www.instagram.com/titaniumheart_
    
        $dom = new DOMDocument();
        @$dom->loadHTMLFile($url);
        $f=$dom->saveHTML();  //load the url (crawl)
    
        $key="";    
        $swquote=0;     
        echo "
    "; for ($x=0;$x"; } if($key=="comments") { //get the number of comments $m=substr($f,$x+12,20); $comments= substr($m,0,strpos($m,"}")); echo "number of comments is ".$comments; echo "
    "; } if($key=="caption") { //get the number of comments $m=substr($f,$x+4,200); $caption= substr($m,0,strpos($m,chr(34))); echo "caption is ".$caption; echo "
    "; } if($key=="likes") { //get the number of comments $m=substr($f,$x+12,20); $likes= substr($m,0,strpos($m,"}")); echo "number of likes is ".$likes; echo "
    "; } if($key=="thumbnail_src") { //get the number of comments $m=substr($f,$x+4,200); $src= substr($m,0,strpos($m,"?")); echo "
    image source is ".$src; echo "
    "; echo ""; echo ""; echo "
    "; } $key=""; } }else { if($swquote==1) { $key.=$c; } } } echo "
    "; }

    usage: https://www.instagram.com/titaniumheart_");?>

    take note: you must enabled extension "php_openssl" on php.ini.

提交回复
热议问题