1

I am trying to get images from my 500px account and display them on my portfolio inside a jQuery slider.

I have no problem with the jQuery slider part but I have never worked with RSS Feed before and I am not sure if that need PHP to pull the data and format it ready for the front-end or if it can simply be done via jQuery.

Any ideas on how I can get started on something like this?

Edit/Update

I hadn't seen that post while looking but having read through it I see how it is useful however it has run me into another problem.

$(document).ready(function(){
        $.ajax({
          type: "GET",
          url: "http://500px.com/daimz/rss.xml",
          dataType: "xml",
          success: parseXml
        });


        // function that parses XML
        function parseXml(xml){

            // find node with name "catalogueResult" and run function for each
            $(xml).find("item").each(function(){

            // variables
            var title = $(this).find("title").text();
            var link = $(this).find("link").text();
            var imgSrc = $(this).find("imageUrl").text();
            var pubDate = $(this).find("pubDate").text();
            var description = $(this).find("h2").text();

            var photoItem= '<img src="'+imgSrc+'" width="275" alt="'+title+'"/>';

            $(".feed").append(photoItem);

        }); 
    }

});

Now this gives me this error:

XMLHttpRequest cannot load http://500px.com/daimz/rss.xml. Origin http://localhost is not allowed by Access-Control-Allow-Origin. 
Daimz
  • 3,243
  • 14
  • 49
  • 76
  • Reading a [RSS with jQuery](http://stackoverflow.com/questions/226663/parse-rss-with-jquery) seems to not be handled by default, but you can use this solution. – j0k Mar 03 '13 at 17:37
  • Did some digging and I think the problem was to do with the xml needing to instead use JSON. So I gave it a try and it now works! I can pull the data all except the image src, I can get the image if I pull 'content' but I don't know how to find the source, I even looked through the load file in chrome inspector which is how I found out content worked. Here is a fiddle to show what I mean you will see the broken image I am tying to pull and the working image below [link](http://jsfiddle.net/FvL4F/) – Daimz Mar 05 '13 at 01:34
  • Well, it seems that inside the 500px feed, there is no field with the direct link to the image ... – j0k Mar 05 '13 at 08:44
  • any ideas how I could move forward I have been trying everything, would paste my code but since it was decided that this question had been asked already (which it hadn't I don't see any other questions about and rss image feed for 500px) I now can't add any more posts, but I really need some help, this is a [jsfiddle](http://jsfiddle.net/FvL4F/) of what I have. – Daimz Mar 07 '13 at 08:53
  • You should use the API instead. Take a look [here](https://github.com/500px/api-documentation/blob/master/endpoints/photo/GET_photos.md) and [here](http://bitly.com/api500px). – j0k Mar 07 '13 at 13:33
  • Just leaving a comment along with my upvote to thank you for reminding me there is an rss feed I can parse in order to get a user's activity on 500px - their API documentation is confusing me very much and this is a great workaround to not lose sight of the small project I am working on. – sebkkom Nov 06 '14 at 11:11

1 Answers1

0

Since an RSS Feed should be valid XML, you can just pull the feed with a jQuery ajax request, and then feed the returned string into a jQuery object (via parseXML()). Then you can access the individual nodes within that new object like you would any DOM node. You shouldn't need PHP at all.

j0k
  • 22,600
  • 28
  • 79
  • 90