hansott / pinterest-php Goto Github PK
View Code? Open in Web Editor NEWπ PHP client for the official Pinterest API (v1)
Home Page: https://developers.pinterest.com
License: MIT License
π PHP client for the official Pinterest API (v1)
Home Page: https://developers.pinterest.com
License: MIT License
Failed to download hansott/pinterest-php from dist: The archive may contain identical file names with different capitalization (which fails on case insensitive filesystems): ZipArchive::extractTo(): Full extraction path exceed MAXPATHLEN (260)
Now trying to download from source
System: Win10
some files are very long name
pinterest-php-master\tests\Pinterest\responses\post_v1_pins_314196580192658592_A_note!_7839fe8158191d9aedc41da6132fff1a_id_link_url_creator_board_created_at_note_color_counts_media_attribution_image_metadata.json
This happens after I auth a new user. All of which works fine. The user has 2 boards.
basically I do this:
$response = $api->getUserBoards();
if (!$response->ok())
{"message": "Invalid parameters.", "type": "api", "param": "creator"}
Any thoughts?
deletePin->658440407994591131
print_r($request):
Pinterest\Http\Request Object
(
[method:Pinterest\Http\Request:private] => DELETE
[endpoint:Pinterest\Http\Request:private] => pins/2147483647/
[params:Pinterest\Http\Request:private] => Array
(
)
[headers:Pinterest\Http\Request:private] => Array
(
)
)
My fix:
Api.php Line 489
< $request = new Request('DELETE', sprintf('pins/%d/', $pinId));
$request = new Request('DELETE', sprintf('pins/%s/', $pinId));
Hello, im new here and i like start use this API
here is my code (one file send.php):
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require DIR . '/vendor/autoload.php';
use Pinterest\App\Scope;
$client = new \Pinterest\Http\BuzzClient();
$appId = '.............';
$appSecret = '...............................';
$auth = new \Pinterest\Authentication($client, $appId, $appSecret);
$url = $auth->getAuthenticationUrl(
'https://www.mysite.com/hansott/send.php',
array(
Scope::READ_PUBLIC,
Scope::WRITE_PUBLIC,
Scope::READ_RELATIONSHIPS,
Scope::WRITE_RELATIONSHIPS,
),
'random-state'
);
if(!ISSET($_GET['code'])){
header('Location: '.$url);
exit();
}
else{
$token = $auth->requestAccessToken($_GET['code']);
$auth = Pinterest\Authentication::onlyAccessToken($client, $token);
$api = new Pinterest\Api($auth);
$response = $api->getCurrentUser();
if (!$response->ok()) {
die($response->getError());
}
$user = $response->result(); // $user instanceof Objects\User
var_dump($user);
}
Thanks you
Hi,
I have installed the PHP Pinterest API on my server and I have authenticated the user using OAuth. When I am trying to get board details I am facing an issue "Notice: Undefined offset: 1 in /vendor/hansott/pinterest-php/src/Pinterest/Http/BuzzClient.php on line 71". I have debugged the issue and found that the key "Pinterest-Generated-By" doesn't have the value. For this please refer Line number 71 in /vendor/hansott/pinterest-php/src/Pinterest/Http/BuzzClient.php
Line cauisng issue,
list($key, $value) = explode(': ', $header);
My code:
$client = new Pinterest\Http\BuzzClient();
$auth = Pinterest\Authentication::onlyAccessToken($client, $token);
$api = new Pinterest\Api($auth);
$response = $api->getUserBoards();
Please let me know why I am facing this issue. And do I need to add value in settings to get the value for "Pinterest-Generated-By"?
Thanks
Pinterest will release version v2 of their API soon: https://developers.pinterest.com/docs/getting-started/introduction/
That also means that I might stop working on this library, I'm happy to fix bugs or security related issues in the meanwhile.
There seems to be no function available to get the pins from a certain board (of the authenticated user).
Would be nice to have this!
Thanks
Hans, Thanks for the code.
Do you have the ability to Save (Re-Pin) a pin.
(I am not referring to Create a pin, which i see you can already do)
Thanks
Hil
Fatal error: Uncaught Pinterest\Api\Exceptions\TokenMissing in /home/socialwe/public_html/pinterestApi/vendor/hansott/pinterest-php/src/Pinterest/Authentication.php:222 Stack trace: #0 /home/socialwe/public_html/pinterestApi/index.php(29): Pinterest\Authentication->requestAccessToken('d4b81156aa5111a...') #1 {main} thrown in /home/socialwe/public_html/pinterestApi/vendor/hansott/pinterest-php/src/Pinterest/Authentication.php on line 222
The current pinterest id like 641763084339350760.
If we call create pin method it will not able to create pin on given board id.
This issue is due to the typecasting.
Hello there,
I do not have API access, can we pin only with access_token? Can you share sample code.
Hey,
Thanks for this library π I did a bit of research and seems like this is the only Pinterest official API PHP wrapper which is being maintained regularly.. π
I have 2 quick questions:
Does it support all API endpoints ? and specifically Does it have methods for following functions:
Thanks.
My Pinterest app is in development. Thanks for any help.
I make my redirect fine --
I get called backed and there is a code --
I get a token from the code.
No matter how I try to create the $auth and $api -- when I try to use the api - I see the error at the bottom
Here's my callback code:
$this->client = new Pinterest\Http\BuzzClient();
$this->auth = new Pinterest\Authentication($this->client,
env('PINTEREST_APP_ID'),
env('PINTEREST_APP_SECRET'));
$code = $_GET['code'];
try {
$token = $this->auth->requestAccessToken($code);
} catch (\Exception $e) {
die('rate limit reached -- try again later');
}
// I have tried both of these and the result is always the same
if (true){
$auth = Pinterest\Authentication::onlyAccessToken($this->client, $token);
} else{
$auth = Pinterest\Authentication::withAccessToken($this->client,
env('PINTEREST_APP_ID', false),
env('PINTEREST_APP_SECRET', false),
$token);
}
$api = new Pinterest\Api($auth);
$response = $api->getCurrentUser(); // always fails.
--- at this point, I get an exception -- see below.
object(Pinterest\Http\Response)[502]
public 'body' =>
object(stdClass)[496]
public 'status' => string 'failure' (length=7)
public 'message' => string 'Authorization failed.' (length=21)
public 'code' => int 3
public 'data' => null
private 'statusCode' => int 401
private 'rawBody' => string '{"status": "failure", "message": "Authorization failed.", "code": 3, "data": null}' (length=82)
private 'headers' =>
array (size=14)
I am not sure, if there's any issue or something but I noticed and got this this error once (*I'm using the api from past 15+ days, i.e., I never noticed this before.).
Fatal error: Uncaught Exception: Operation timed out after 5000 milliseconds with 0 bytes received in /Users/narainsagar/www/SweepWidgetLive/vendor/hansott/pinterest-php/src/Pinterest/Http/BuzzClient.php on lineΒ 123 --
$image = Pinterest\Image::file('images.jpg');
$response = $api->createPin('746612513164716763', "test func", $image, "https://website.com");
if (!$response->ok()) {
die($response->getError());
}
failed: Parameter 'board' is required.
Hi @hansott I just noticed there's getUserPins
method already implemented in the code but it doesn't seems to be mentioned in the docs.. Thanks
Hi, how can we use proxy for api requests?
Hi,
I am also facing the same issue
I have installed the PHP Pinterest API on my server and I have authenticated the user using OAuth. When I am trying to get board details I am facing an issue "Notice: Undefined offset: 1 in /vendor/hansott/pinterest-php/src/Pinterest/Http/BuzzClient.php on line 71". I have debugged the issue and found that the key "Pinterest-Generated-By" doesn't have the value. For this please refer Line number 71 in /vendor/hansott/pinterest-php/src/Pinterest/Http/BuzzClient.php
Line cauisng issue,
list($key, $value) = explode(': ', $header);
My code:
$client = new Pinterest\Http\BuzzClient();
$auth = Pinterest\Authentication::onlyAccessToken($client, $token);
$api = new Pinterest\Api($auth);
$response = $api->getUserBoards();
Please let me know why I am facing this issue. And do I need to add value in settings to get the value for "Pinterest-Generated-By"?
Thanks
Hi, I have a problem when authorizing my code to token. I have tried the javascript version and it works fine but I need to do with PHP. Here is the code.
$client = new Pinterest\Http\BuzzClient();
$clientId = "xxx";
$clientSecret = "xxx";
$auth = new Pinterest\Authentication($client, $clientId, $clientSecret);
if(empty($_GET["code"])){
$callbackurl = 'mycallbackurl';
$url = $auth->getAuthenticationUrl(
$callbackurl,
array(
Scope::READ_PUBLIC,
Scope::WRITE_PUBLIC,
Scope::READ_RELATIONSHIPS,
Scope::WRITE_RELATIONSHIPS,
),
'random-string'
);
header('Location: ' . $url);
exit;
}
else{
$code = $_GET['code'];
$token = $auth->requestAccessToken($code);
echo $token; --> here is the error
}
It produces code but the problem is when the code is converted into a token. That gave this following error.
Fatal error: Uncaught Pinterest\Api\Exceptions\TokenMissing in /home/admin/ocicio/botsector/vendor/hansott/pinterest-php/src/Pinterest/Authentication.php:222 Stack trace: #0 /home/admin/ocicio/botsector/index.php(31): Pinterest\Authentication->requestAccessToken('d77eecdc2dae2ad...') #1 {main} thrown in /home/admin/ocicio/botsector/vendor/hansott/pinterest-php/src/Pinterest/Authentication.php on line 222
Hi,
We are using the Pinterest API to add pins in our Boards. We have figured out the steps in PHP to get access token and create pins in our board. On proceeding further with our development we have few doubts,
We came across a option called "Section" in each board. We have researched to find the PHP code for creating the section in a board. But we can't able to get any reference for creating sections in a board. So can anyone help us by providing any reference to create sections.
We tried to try the advertisement in Pinterest Campaign, but in Step #3 it is allowing us to select only one pin at a time for campaign promotion. I tried with different types of promotions but I can't able to select multiple pins at a time for promotion. Can we able to select multiple pins in the ads manager? Or is there any API to manager the ads and the campaigns, so we can control it through automation. Please let us know your suggestions.
Thanks
Hi,
I am using this API for managing boards and pins of Pinterest. In this API, I can't able to find the function for "Edit Pins". Can you please add the function and release the new file as soon as possible.
And do you have any reference to managing the Pinterest Campaigns and Ads through API?
Waiting for your response.
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.