Giter VIP home page Giter VIP logo

convertkitsdk-php's People

Contributors

bogusred avatar fideloper avatar growdev avatar iamcaptaincode avatar intellow avatar jeroenvanrensen avatar jhull avatar n7studios avatar tnorthcutt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

convertkitsdk-php's Issues

get_subscriber_id() causes 429 "Too many requests" API error when total pages > 120

The exact number of pages seems to vary, but calling this function is very slow and eventually causes the API to throw a 429 error for an account with lots of subscribers, because it queries the API for all subscribers and searches the results instead of searching the API directly for the provided email.

It is possible to search by email when listing subscribers using the email_address parameter according to https://developers.convertkit.com/#list-subscribers

Adding the email_address parameter to $options in get_subscriber_id() should fix this issue.

ConvertKit_API::create_custom_field() does not support multiple fields creation

Is your feature request related to a problem? Please describe.

CK API supports creating multiple tags in one go.
See API: https://developers.convertkit.com/#create-field (note the Multiple custom fields example).

The \ConvertKit_API\ConvertKit_API::create_custom_field() method does not support this behavior allowing only a single tag per request to be created.

Describe the solution you'd like

Modify \ConvertKit_API\ConvertKit_API::create_custom_field() to support not just the string parameter as a single field label, but also accepting an array OR always accepting an array (even with a single field label).

Describe alternatives you've considered

I had to implement a copy of this method that basically does this:

$options = [ 'api_secret' => $this->api_secret ];

foreach ( $field_labels as $label ) {
	$options['label'][] = [ 'name' => $label ];
}

return $this->post( 'custom_fields', $options );

Additional context

No response

Make ConvertKit_API::create_log() protected

Is your feature request related to a problem? Please describe.

When the debugging needs to be enabled on a live site (don't ask, clients' sites), the API key is logged into a publicly available file.
That's because reconfiguring the whole site to make that log file outside of the server access is not possible - so the log file public.
So scrappers etc can accidentally see the API key.

Example of the record:

[2023-07-16T19:58:19.753138+00:00] ck-debug.INFO: GET, Request body: {"api_key":"abc1234567890def"} [] []

Describe the solution you'd like

In order to more or less easily modify the behavior without rewriting the implementation, I'd like to be able to parse the message that is sent - and prevent the API key leaking into the log.

The easiest solution - overload the ConvertKit_API::create_log() method in a parent class that extends the default ConvertKit_API. After that - do the easy search-replace to remove the API key.

Right now it's impossible because that method is private.

Can you please make it protected?

Describe alternatives you've considered

No response

Additional context

No response

API queries super slow with SDK

Hey there,

Been struggling with the API queries taking most often 22 seconds to respond. I thought the API itself was to blame, but turned out that calling the API with cURL from bash was super fast.

Figured out the culprit:

/**
 * Querying the ConvertKit API from curl like so is super fast:
 * curl https://api.convertkit.com/v3/subscribers?api_secret=APIKEY&[email protected]
 *
 * BUT, calling it with the official ConvertKit PHP SDK is super slow, with
 * speeds of 22 seconds.
 *
 * Here are some comparisons.
 * Run these routes one at a time.
 */

// Official ConvertKit PHP SDK.
// SUPER SLOW. Often takes 22 seconds.
$app->get('/tests/convertkit/sdk/', function ($request, $response, $args) {
    $api = new \ConvertKit_API\ConvertKit_API(
        getenv('CONVERTKIT_API_KEY'),
        getenv('CONVERTKIT_API_SECRET'),
    );

    $subscriber_id = $api->get_subscriber_id( '[email protected]' ); // 937488134
    $response->getBody()->write(strval($subscriber_id));
    return $response;
});


// Basic file_get_contents.
// SUPER SLOW. Often takes 22 seconds.
$app->get('/tests/convertkit/file_get_contents/basic/', function ($request, $response, $args) {
    $url = "https://api.convertkit.com/v3/subscribers?api_secret="
      . getenv('CONVERTKIT_API_SECRET')
      . "&[email protected]";
    $result = file_get_contents($url);

    var_dump(json_decode($result, true));

    return $response;
});

// file_get_contents with context trick.
//   See https://stackoverflow.com/a/4240241/1717535
// Fast. Under a second.
$app->get('/tests/convertkit/file_get_contents/context/', function ($request, $response, $args) {
    $url = "https://api.convertkit.com/v3/subscribers?api_secret="
      . getenv('CONVERTKIT_API_SECRET')
      . "&[email protected]";
    $context = stream_context_create(array('http' => array('header'=>'Connection: close\r\n')));
    $result = file_get_contents($url, false, $context);

    var_dump(json_decode($result, true));

    return $response;
});

// with curl
// Fast. Under a second.
$app->get('/tests/convertkit/curl/', function ($request, $response, $args) {
    $url = "https://api.convertkit.com/v3/subscribers?api_secret="
      . getenv('CONVERTKIT_API_SECRET')
      . "&[email protected]";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_URL, $url);
    $result=curl_exec($ch);
    curl_close($ch);

    var_dump(json_decode($result, true));

    return $response;
});

This is on PHP 7.4.4 and 7.4.8. (The examples use Slim Framework.)

You should be able to confirm this for yourself.

I wasted so much time with this… (Support was very slow to respond.)

For me, this makes the PHP SDK unusable. These are also serious concerns:

Please note that since ConvertKitSDK-PHP is not yet versioned, your project will always download the latest files from master every time you run composer install which may subject you to breaking changes in the future. – from the docs

Package jeremeamia/superclosure is abandoned, you should avoid using it. Use opis/closure instead. – Composer warning

I'm a paid customer, but wary of using ConvertKit because of this.

Invalid filename

Main class is named ConvertKit_API while the filename is ConvertKitAPI (without "_"), therefore the psr-4 loader doesn't work.

Package update

Hi, I was wondering if this package is going to be updated, the last commit was 2 years a. go, with the recent releases of php will this be upgraded?

Thanks

ConvertKit_API::create_tag() does not support multiple tags creation

Is your feature request related to a problem?

CK API supports creating multiple tags in one go.
See API: https://developers.convertkit.com/#create-a-tag (note the Multiple tags example).

The \ConvertKit_API\ConvertKit_API::create_tag() method does not support this behavior allowing only a single tag per request to be created.

Describe the solution you'd like

Modify \ConvertKit_API\ConvertKit_API::create_tag() to support not just the string parameter as a single tag name, but also accepting an array OR always accepting an array (even with a single tag name).

Describe alternatives you've considered

I had to implement a copy of this method that basically does this:

$options = [ 'api_secret' => $this->api_secret ];

foreach ( $tag_labels as $label ) {
	$options['tag'][] = [ 'name' => $label ];
}

return $this->post( 'tags', $options );

Packagist

Hi Guys,

I'm added this repo to Packagist. Follow instructions and contact the Packagist to owned like as mantainers:

This package is not auto-updated. Please set up the GitHub Hook for Packagist so that it gets updated whenever you push!
There is no license information available for the latest version (dev-master) of this package.

Monolog Issue, Won't Install

Trying to install through composer and I'm getting this:

 Conclusion: remove monolog/monolog 2.0.2
    - Conclusion: don't install monolog/monolog 2.0.2
    - convertkit/convertkitapi dev-master requires monolog/monolog ^1.0

Installation Error requires guzzle ^6.3 and I have 7

The command:

composer require convertkit/convertkitapi:dev-master

Problem 1
- Root composer.json requires convertkit/convertkitapi dev-master -> satisfiable by convertkit/convertkitapi[dev-master].
- convertkit/convertkitapi dev-master requires guzzlehttp/guzzle ^6.3 -> found guzzlehttp/guzzle[6.3.0, ..., 6.5.x-dev] but it conflicts with your root composer.json require (^7.0.1).

My guzzle version from composer.json:

    "guzzlehttp/guzzle": "^7.0.1",

Make make_request method public

Can you convert the make_request method from private to public? This will allow users to make requests to API endpoints whose methods are not implemented in the library?

For Example:

I want to get a list of all tags by calling v3/tags but there is no such method. How could I do that?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.