Comments (8)
It seems to be because of this:
if ( $response->getResponseCode() >= 400 ) {
throw new PinterestException( 'Pinterest error (code: ' . $response->getResponseCode() . ') with message: ' . $response->message, $response->getResponseCode() );
}
I'm getting a 401
response code, I don't know why ... And the message property doesn't exist.
Why would it throw a 401 response, since the authentication before went all fine, (authorising the app to access data from pinterest user).
Also, everything worked before this new change on the api/package, so not sure what's going wrong now.
from pinterest-api-php.
When I var_dump the $resonse_data
variable, it has: "{"error": "invalid_grant"}"
According to the docs however, it's correct.
https://developers.pinterest.com/docs/api/overview/
grant_type Must take the value authorization_code.
from pinterest-api-php.
In the Request class, I dump the following:
// Execute request and catch response
$response_data = $ch->execute();
dd($ch->getErrors(), $ch->hasErrors(), $response_data);
which returns:
""
0
"{"error": "invalid_grant"}"
So it says it doesn't have any errors, but the $response_data
does contain an error.
from pinterest-api-php.
Thanks for your excellent debugging! 👍
I might check this one out at the end of the day. The origin of the issue is probably related to Pinterest changing something in their API/oAuth process, but it looks like the response class/error handling of the wrapper needs some updating too.
from pinterest-api-php.
Ok I just checked some things:
I have a simple running version of the package running on my server which is working fine. The code it's using is the following:
boot.php (required in index.php and callback.php):
require "vendor/autoload.php";
use DirkGroenen\Pinterest\Pinterest;
$pinterest = new Pinterest(secret, secret);
if(isset($_GET["code"])){
$token = $pinterest->auth->getOAuthToken($_GET["code"]);
$pinterest->auth->setOAuthToken($token->access_token);
}
if(isset($_GET["access_token"])){
$pinterest->auth->setOAuthToken($_GET["access_token"]);
}
index.php:
<body>
<h1>Login with Pinterest</h1>
<p>Use this <a href="<?php echo $pinterest->auth->getLoginUrl('https://bitlabs.nl/pinterest/callback.php', array('read_public')); ?>">link to login</a> with your Pinterest account.</p>
</body>
callback.php:
<h1>Hey you!</h1>
<pre>
<?php var_dump($pinterest->users->me()); ?>
</pre>
Can you check your code against the above?
from pinterest-api-php.
I have the same setup basically, only in a framework.
I have:
- view 1 which shows link to login
- this redirects to back to
callback
method on controller - callback method does the
$pinterest->auth->getOAuthToken($_GET["code"]);
, which throws the error mentioned.
from pinterest-api-php.
Ok I just refreshed the page, and now for some reason I do have an access_token.
I'm not sure what happened.
Sorry for the trouble and thanks for you support! 👍
from pinterest-api-php.
Strange stuff happens. Let me know if it somehow comes back.
from pinterest-api-php.
Related Issues (20)
- Fatal error Pinterest error (code: 500) HOT 1
- Fatal error: Uncaught Error: Class 'PHPUnit_Framework_TestCase' not found HOT 1
- Laravel 6 compatibility? HOT 3
- Not pining HOT 4
- You should be redirected automatically to target URL HOT 1
- pin send error HOT 5
- can't pin an image to Pinterest but no error sent HOT 6
- request empty in create pin HOT 3
- getMeBoards not working HOT 2
- how can be scheduled images to go live at a later date on pinterest using api in php? HOT 1
- invalid_grant when trying to convert a JS access code for an access_token HOT 9
- ACCESS_TOKEN Pin Sharing HOT 2
- Project status HOT 1
- getting error message "API method not found"
- Support of Pinterest API (v5) HOT 3
- Video pin?
- How to use fromBoard method? HOT 2
- New Section HOT 1
- Request to correct instructions HOT 2
- Sanitize board name HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pinterest-api-php.