3

I managed to retrieve all the basic info about a medium.com publication via JSON using file_get_contents("https://medium.com/publication_name/latest?format=json"); however is there a way to retrieve the name and photo of the author of the posts?

drake035
  • 3,955
  • 41
  • 119
  • 229

2 Answers2

0

Given a JSON payload that resembles this:

{
    "payload": {
        "posts": [
            {
                "creatorId": "foobar",
                "title": "How to foo your bars"
            }
        ],
        "references": {
            "User": {
                "foobar": {
                    "userId": "foobar",
                    "name": "Senor Foobar",
                    "imageId": "baz.jpg"
                }
            }
        }
    }
}

The creatorId for a post also exists in the references's User key. In this example I have used the id foobar. From that key you can fetch the author name and filename for the author photo.

Translating the author photo filename to a URL may require more work. The current CDN is https://cdn-images-1.medium.com/fit/c/60/60/ and so the full URL would be https://cdn-images-1.medium.com/fit/c/60/60/foobar.jpg. This CDN is likely to change over time so this URL is not absolute.

The information about the CDN is not available in the JSON payload and was found by inspecting the source for a sample Medium article.

anothermh
  • 9,815
  • 3
  • 33
  • 52
  • Thanks. Weirdly the value of the "name" field located under "references" is a different name from the one of the actual post author. Elsewhere the name of the author does appear but it's located under this field: "5dc17e596272":{ "userId":"5dc17....272", "name":"Whatever", "username":"what.ever". That means I can't really access it programmatically. How twisted is that! – drake035 May 06 '17 at 19:53
0

If you use the below link you could get author details. replace your user name instead of <@publication_name>

https://api.rss2json.com/v1/api.json?rss_url=https://medium.com/feed/<@publication_name> 
VLAZ
  • 26,331
  • 9
  • 49
  • 67
Sabesan
  • 654
  • 1
  • 10
  • 17