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

I am unable to reuse the PublisherAPI object to do more than one request #4

Open
JonathanAquino opened this issue Jul 21, 2016 · 2 comments

Comments

@JonathanAquino
Copy link

// Expected: I should be able to call get() twice, or get() then Post(), on a $PublisherAPI object.
// Actual: I get an error if I call get() twice on a $PublisherAPI object. If I create a second $PublisherAPI object for the second get() call, then it works.


Code:

<?php
$api_key_id = "...";
$api_key_secret = "...";
$endpoint = "https://news-api.apple.com";

$PublisherAPI = new ChapterThree\AppleNewsAPI\PublisherAPI(
  $api_key_id,
  $api_key_secret,
  $endpoint
);

$response = $PublisherAPI->get('/channels/{channel_id}',
  [
    'channel_id' => '...'
  ]
);

$response = $PublisherAPI->get('/channels/{channel_id}',
  [
    'channel_id' => '...'
  ]
);

Output:

Warning: curl_setopt(): 123 is not a valid cURL handle resource in /home/prod/yoko/build/migrate-to-sf-colo/target/dependencies/thirdparty-php-curl-class-tar.gz/src/Curl/Curl.php on line 887

Warning: curl_setopt(): 123 is not a valid cURL handle resource in /home/prod/yoko/build/migrate-to-sf-colo/target/dependencies/thirdparty-php-curl-class-tar.gz/src/Curl/Curl.php on line 887

Warning: curl_setopt(): 123 is not a valid cURL handle resource in /home/prod/yoko/build/migrate-to-sf-colo/target/dependencies/thirdparty-php-curl-class-tar.gz/src/Curl/Curl.php on line 887

Warning: curl_setopt(): 123 is not a valid cURL handle resource in /home/prod/yoko/build/migrate-to-sf-colo/target/dependencies/thirdparty-php-curl-class-tar.gz/src/Curl/Curl.php on line 887

Warning: curl_exec(): 123 is not a valid cURL handle resource in /home/prod/yoko/build/migrate-to-sf-colo/target/dependencies/thirdparty-php-curl-class-tar.gz/src/Curl/Curl.php on line 349

Warning: curl_errno(): 123 is not a valid cURL handle resource in /home/prod/yoko/build/migrate-to-sf-colo/target/dependencies/thirdparty-php-curl-class-tar.gz/src/Curl/Curl.php on line 350

Warning: curl_error(): 123 is not a valid cURL handle resource in /home/prod/yoko/build/migrate-to-sf-colo/target/dependencies/thirdparty-php-curl-class-tar.gz/src/Curl/Curl.php on line 352

Warning: curl_getinfo(): 123 is not a valid cURL handle resource in /home/prod/yoko/build/migrate-to-sf-colo/target/dependencies/thirdparty-php-curl-class-tar.gz/src/Curl/Curl.php on line 415

Notice: Undefined offset: 2 in /home/prod/yoko/build/migrate-to-sf-colo/target/dependencies/thirdparty-php-curl-class-tar.gz/src/Curl/Curl.php on line 428

Notice: Array
(
    [code] => 
    [message] => 
    [response] => 
)
@sgpopsugar
Copy link

sgpopsugar commented Apr 14, 2017

same problem here. Second call fails ((delete -> post) ).

UPDATE:
The only way to overcome it is to use new object (new PublisherAPI) OR to populate "client" property of PublisherAPI object with new \Curl\Curl object

@serjgama
Copy link

@JonathanAquino

Should fix the problem: #19

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

3 participants