unsplash / unsplash-photopicker-ios

📱An iOS photo picker to search and download photos from Unsplash.
MIT License
406 stars 85 forks source link

Getting author urls #13

Closed Vlada31R closed 5 years ago

Vlada31R commented 5 years ago

Hi, I am using your sdk, but I have some problems with getting photo's author links. As I understand from API, I am getting it in format

{ "id": "pXhwzz1JtQU", "updated_at": "2016-07-10T11:00:01-05:00", "username": "jimmyexample", "name": "James Example", "first_name": "James", "last_name": "Example", "instagram_username": "instantgrammer", "twitter_username": "jimmy", "portfolio_url": null, "bio": "The user's bio", "location": "Montreal, Qc", "total_likes": 20, "total_photos": 10, "total_collections": 5, "followed_by_user": false, "followers_count": 300, "following_count": 25, "downloads": 225974, "profile_image": { "small": "https://images.unsplash.com/face-springmorning.jpg?q=80&fm=jpg&crop=faces&fit=crop&h=32&w=32", "medium": "https://images.unsplash.com/face-springmorning.jpg?q=80&fm=jpg&crop=faces&fit=crop&h=64&w=64", "large": "https://images.unsplash.com/face-springmorning.jpg?q=80&fm=jpg&crop=faces&fit=crop&h=128&w=128" }, "badge": { "title": "Book contributor", "primary": true, "slug": "book-contributor", "link": "https://book.unsplash.com" }, "links": { "self": "https://api.unsplash.com/users/jimmyexample", "html": "https://unsplash.com/jimmyexample", "photos": "https://api.unsplash.com/users/jimmyexample/photos", "likes": "https://api.unsplash.com/users/jimmyexample/likes", "portfolio": "https://api.unsplash.com/users/jimmyexample/portfolio" } }

So I need to add coding field "link" to UnsplashUser, but I am getting error "typeMismatch". Please help me, and I will be very glad if you add this to your sdk, because this is necessary for following Unsplash guidelines. Or maybe there are other ways of solving this problem. Thanks.

ocollet commented 5 years ago

@Vlada31R Thank you for your feedback, that's a valid issue.

ocollet commented 5 years ago

@Vlada31R To access the URL, you can use the links property like this: photo.links[.html].

Vlada31R commented 5 years ago

Thank you for your answer. But this URL is not the same as URL(string: "https://unsplash.com/@\(photo.user.username)") or it is okey? As I understood I need link to author portfolio.

ocollet commented 5 years ago

Sorry, I meant photo.user.links[.html]. Don't forget to add the UTM at the end of the URL: https://help.unsplash.com/en/articles/2511315-guideline-attribution

Thank you!