Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Requests CURL returns empty response #91

Open
Zubaja opened this issue Mar 7, 2022 · 0 comments
Open

API Requests CURL returns empty response #91

Zubaja opened this issue Mar 7, 2022 · 0 comments

Comments

@Zubaja
Copy link

Zubaja commented Mar 7, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant