Patreon / patreon-php

Interact with the Patreon API via OAuth
Apache License 2.0
145 stars 41 forks source link

API Requests CURL returns empty response #91

Open Zubaja opened 2 years ago

Zubaja commented 2 years ago

Whilst trying to retrieve data from my campaign so that I can get a list of all my current patrons, all API requests return an empty response. When replicating the request in Postman I do get a response such as campaign data.

What do I use:

What I've tried:

Expected result:

Actual result:

My code:

<?php

namespace App\Controller\Patreon;

use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;

use Patreon\API;
use Patreon\OAuth;

class PatreonController extends AbstractController
{
    private $clientId = '...';
    private $clientSecret = '...';
    private $accessToken = '...';
    private $refreshToken = '...';
    private $apiClient = null;
    private $oAuthClient = null;

    public function __construct()
    {
        $this->apiClient = new API($this->accessToken);
        $this->oauthClient = new OAuth($this->clientId, $this->clientSecret);

        $this->apiClient->api_return_format = "json";
    }

    /**
     * @Route("/api/patrons/get/", name="get_patrons", methods={"GET"})
     */
    public function getPatrons(): JsonResponse
    {
        $patrons = [];

        $campaign_response = $this->apiClient->fetch_campaign_details(...); // This one right here, officer
        if($campaign_response) {
            // ...
        }

        return new JsonResponse(["patrons" => $patrons], Response::HTTP_OK);
    }
}

I have attempted to see if other calls ($this->apiClient->fetch_user(), for instance) return data, but all of them come up empty.