Commenting, Upvoting and Uploading Photos with the 500px API


Originally published at:

This entry is part 2 of 2 in the series Building a Custom 500px Laravel App

Building a Custom 500px Laravel App

In the first part of this series we used the API to get the latest photos from 500px and filter through them, and we built a user profile with the list of associated photos. In this part, we are going to give the user the ability to vote, favorite and comment on photos, and finally, we will give the users the ability to upload their own photos. Let’s get started.


When trying to access an API endpoint we need to check the authentication level required to access the resource. The API may require a consumer_key or an OAuth.

In the first part we registered a new application on 500px and received our consumer_key and consumer_secret. We use the Grant app to get a valid token and token_secret for testing.


After specifying your consumer_key and consumer_secret, you receive a token and a token_secret. These are going to give you the right to post and retrieve user content.

// bootstrap/start.php

App::singleton('pxoauth', function(){
    $host = '';
    $consumer_key = 'YOUR CONSUMER KEY';
    $consumer_secret = 'YOUR CONSUMER SECRET';
    $token = 'GRANT TOKEN';
    $token_secret = 'GRANT TOKEN SECRET';

    $oauth = new PxOAuth($host, $consumer_key, $consumer_secret, $token, $token_secret);

    return $oauth;

The PxOAuth class wraps our communication with the 500px API.

Building a Custom 500px Laravel App

<< Popular Photos, Filters and User Profiles with the 500px API

Continue reading this article on SitePoint


closed #2

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.