Closed BurakBoz closed 4 years ago
What is the error you're receiving?
We've suddenly started receiving 308 Permanent Redirect
responses from the Pinterest API today. No changes to our app or codebase in ages. No apparent changes to the Pinterest API docs that'd explain it, either.
@BurakBoz We've discovered on our end that the API appears to be requiring the fields
parameter be set. This used to be optional (and the docs still say it is) but specifying an array of fields seems to make the API work again.
@BurakBoz
Here is git diff of a workaround I did in our code:
try {
- return $this->pinterest->pins->create($postData);
+
+ if (array_key_exists("image", $postData)) {
+ if (class_exists('\CURLFile')) {
+ $data["image"] = new \CURLFile($postData['image']);
+ } else {
+ $data["image"] = '@' . $postData['image'];
+ }
+ }
+
+ $response = $this->pinterest->request->post("pins/?fields=id,link,note,url", $postData);
+
+ return new \DirkGroenen\Pinterest\Models\Pin($this->pinterest, $response);
.
.
.
$this->pinterest
is the instance of the Pinterest service
It seems from now on Pinterest requires "/" slash at the end of endpoint url.
Endpoints/Pins.php:66 $response = $this->request->post("pins", $data); I've change this line simple slash fixed redirection error $response = $this->request->post("pins/", $data);
also we have this error is on other classes like Users.php
$response = $this->request->get("me/boards", $data);
to
$response = $this->request->get("me/boards/", $data);
so it's simple. slash is the solution for this sudden Pinterest API update.
There is an endpoint url error on pining please check it It may be temporary error I don't know yet