foursquarephotos

How do I use the link for a Foursquare photo?


I am trying to use the foursqaure API via the HTTP requests. So I send a http request looking similar to this ->

https://api.foursquare.com/v2/venues/explore?ll=40.7,-74&venuePhoto=1&oauth_token=(OAUTH_TOKEN)&v=20151015

I get one massive JSON object with a bunch of data and inside the data I find the photos Prefix and suffix.

My problem is when I try and use the &venuePhoto=1.

I get a prefix and suffix for what seems to be 1 picture in the following form.

prefix: "https://irs1.4sqi.net/img/general/"
suffix: "/63892328_N0A_9qgk0N30lHiqDWIRtNb-0YfO84BIxHc9SP7h4rY.jpg"

I can not seem to get this string to get me the picture. If I put them together even without one of the "/" slashes it still does not give me a picture.I have already tried a whole bunch of things.

I thought adding this option to the request URL I can void using the photo part of the api and get everything in 1 go. AM I missing something? Should I be using some other part of the API to get the pictures.?


Solution

  • You need to specify the size of image.

    prefix + "100x100" + suffix
    

    e.g. https://irs1.4sqi.net/img/general/100x100/63892328_N0A_9qgk0N30lHiqDWIRtNb-0YfO84BIxHc9SP7h4rY.jpg

    See also Foursquare API document

    To assemble a resolvable photo URL, take prefix + size + suffix, e.g. https://irs0.4sqi.net/img/general/300x500/2341723_vt1Kr-SfmRmdge-M7b4KNgX2_PHElyVbYL65pMnxEQw.jpg.

    size can be one of the following, where XX or YY is one of 36, 100, 300, or 500.

    • XXxYY
    • original: the original photo's size
    • capXX: cap the photo with a width or height of XX (whichever is larger). Scales the other, - smaller dimension proportionally
    • widthXX: forces the width to be XX and scales the height proportionally
    • heightYY: forces the height to be YY and scales the width proportionally