unsplash / unsplash-php

👻 Official PHP wrapper for the Unsplash API
MIT License
409 stars 71 forks source link

How to find the information for the attribution #100

Open RoqueCampos opened 5 years ago

RoqueCampos commented 5 years ago

Hi!

I'm not sure if I'm missing something, but I'm not able to find the information of the photographer for the attribution.

WHen getting a random photo, I call photo->download() and with that I get a download link. Thats fine. When calling photo->photographer(), the only information insider is the username.

I used the username to retrieve the User object, but again, inside there is not information for the attribution (Firstname, Lastname).

What I'm doing wrong?

Thanks.

lukechesser commented 5 years ago

@RoqueCampos when I fetch the JSON from the API, it has the full photographer details available on the random endpoint:

{
  "id": "xNDFrCge8c4",
  "created_at": "2019-07-11T15:58:56-04:00",
  "updated_at": "2019-07-28T01:09:06-04:00",
  "width": 2829,
  "height": 3536,
  "color": "#252B2F",
  "description": null,
  "alt_description": "waver waves during daytime",
  "urls": {
    "raw": "https://images.unsplash.com/photo-1562874724-b33411b38141?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjIwMzJ9",
    "full": "https://images.unsplash.com/photo-1562874724-b33411b38141?ixlib=rb-1.2.1&q=85&fm=jpg&crop=entropy&cs=srgb&ixid=eyJhcHBfaWQiOjIwMzJ9",
    "regular": "https://images.unsplash.com/photo-1562874724-b33411b38141?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=1080&fit=max&ixid=eyJhcHBfaWQiOjIwMzJ9",
    "small": "https://images.unsplash.com/photo-1562874724-b33411b38141?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=400&fit=max&ixid=eyJhcHBfaWQiOjIwMzJ9",
    "thumb": "https://images.unsplash.com/photo-1562874724-b33411b38141?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=200&fit=max&ixid=eyJhcHBfaWQiOjIwMzJ9"
  },
  "links": {
    "self": "https://api.unsplash.com/photos/xNDFrCge8c4",
    "html": "https://unsplash.com/photos/xNDFrCge8c4",
    "download": "https://unsplash.com/photos/xNDFrCge8c4/download",
    "download_location": "https://api.unsplash.com/photos/xNDFrCge8c4/download"
  },
  "user": {
    "id": "Vs5z87iQYAY",
    "updated_at": "2019-08-04T11:15:34-04:00",
    "username": "yuli_superson",
    "name": "Yuliya Kosolapova", <===============================================
    "first_name": "Yuliya",
    "last_name": "Kosolapova",
    "twitter_username": null,
    "portfolio_url": "https://www.instagram.com/yuli_superson/",
    "bio": "Follow me on facebook.com/trankvillina",
    "location": "Russia, Moscow",
    "links": {
      "self": "https://api.unsplash.com/users/yuli_superson",
      "html": "https://unsplash.com/@yuli_superson",
      "photos": "https://api.unsplash.com/users/yuli_superson/photos",
      "likes": "https://api.unsplash.com/users/yuli_superson/likes",
      "portfolio": "https://api.unsplash.com/users/yuli_superson/portfolio",
      "following": "https://api.unsplash.com/users/yuli_superson/following",
      "followers": "https://api.unsplash.com/users/yuli_superson/followers"
    },
    "profile_image": {
      "small": "https://images.unsplash.com/profile-1542573282965-bd0ef4147e78?ixlib=rb-1.2.1&q=80&fm=jpg&crop=faces&cs=tinysrgb&fit=crop&h=32&w=32",
      "medium": "https://images.unsplash.com/profile-1542573282965-bd0ef4147e78?ixlib=rb-1.2.1&q=80&fm=jpg&crop=faces&cs=tinysrgb&fit=crop&h=64&w=64",
      "large": "https://images.unsplash.com/profile-1542573282965-bd0ef4147e78?ixlib=rb-1.2.1&q=80&fm=jpg&crop=faces&cs=tinysrgb&fit=crop&h=128&w=128"
    },
    "instagram_username": "yuli_superson",
    "total_collections": 15,
    "total_likes": 660,
    "total_photos": 282,
  },
  ...
}
lukechesser commented 5 years ago

@RoqueCampos does #102 change anything/help?