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:
Symfony 6.0.* (6.0.5 as of posting)
Patreon-php ^1.0.0
PHP 8.0.3
What I've tried:
Use the built-in functions to request my current campaign
Replicate the CURL method manually to request my current campaign
Expected result:
JSON response
Actual result:
Empty response
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.
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:
I have attempted to see if other calls (
$this->apiClient->fetch_user()
, for instance) return data, but all of them come up empty.