Quantcast
Channel: instagram feed on website - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Answer by Jeff for instagram feed on website

$
0
0

In your HTML you should include a JavaScript 'script' element where you do something called an AJAX Request. The request will access the PHP file that produces the Instagram feed. ECHO the result from the PHP file and it will be returned into the DATA variable in the AJAX request. The request looks roughly like this:

                $.ajax({
                     method: ‘POST or GET, most likely POST’,
                      url:  ‘not always an actual url, this is the path to your PHP file’,
                      success: function(data) {
                         //php file returns into variable ‘data’
                        //display the feed within this function
                      }
                    });

The result from the PHP file should be echo’d back in JSON notation, if it isn’t, just add this to end of PHP the file:

   $whatever = json_encode($your_result);
   echo $whatever; //this is still the feed, just encoded in JSON

And if you need to decode it for some reason, just do

   json_decode($variable_to_decode);

There are other parameters you can use in the AJAX request, like if for instance you need access to certain variables in your PHP file, that currently only exist in your HTML document.


Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>