dirkgroenen / pinterest-api-php

A PHP wrapper for the official Pinterest API. :pushpin:
https://developers.pinterest.com/docs/getting-started/introduction/
Apache License 2.0
173 stars 76 forks source link

please how can i solve this , i can't retrieve user info #2

Closed composercodes closed 8 years ago

composercodes commented 9 years ago

Warning: curl_setopt_array(): CURLOPT_FOLLOWLOCATION cannot be activated when an open_basedir is set in /var/www/vhosts/showmb.com/dev1/maged/DirkGroenen/Pinterest/Utils/CurlBuilder.php on line 70

Fatal error: Uncaught exception 'DirkGroenen\Pinterest\Exceptions\PinterestException' with message 'Pinterest error (code: 401) with message: Authorization failed.' in /var/www/vhosts/showmb.com/dev1/maged/DirkGroenen/Pinterest/Transport/Request.php:196 Stack trace: #0 /var/www/vhosts/showmb.com/dev1/maged/DirkGroenen/Pinterest/Transport/Request.php(78): DirkGroenen\Pinterest\Transport\Request->execute('GET', 'https://api.pin...') #1 /var/www/vhosts/showmb.com/dev1/maged/DirkGroenen/Pinterest/Endpoints/Users.php(28): DirkGroenen\Pinterest\Transport\Request->get('me', Array) #2 /var/www/vhosts/showmb.com/dev1/maged/init.php(41): DirkGroenen\Pinterest\Endpoints\Users->me(Array) #3 /var/www/vhosts/showmb.com/dev1/maged/index.php(16): include('/var/www/vhosts...') #4 {main} thrown in /var/www/vhosts/showmb.com/dev1/maged/DirkGroenen/Pinterest/Transport/Request.php on line 196
dirkgroenen commented 9 years ago

This is more a problem of your PHP configuration. Please check this thread (or drop the error google and look through the results) to fix it for now.

In case anyone else is having the same questions I might check to create a workaround in the code.

composercodes commented 9 years ago

@dirkgroenen Please can i give you my ftp details and you check where is the wrong , might be wrong with code , Please can you help me Thanks,

dirkgroenen commented 9 years ago

You can paste the relevant parts of the code here or on something like codebin. Please make sure you've checked the sites from my previous response.

composercodes commented 9 years ago

@dirkgroenen Please last question I need to get count of followers , It come as a collection how to get count . { "data": [ { "url": "https:\/\/www.pinterest.com\/ben\/", "first_name": "Ben", "last_name": "Silbermann", "id": "123456" }, { "url": "https:\/\/www.pinterest.com\/evan\/", "first_name": "Evan", "last_name": "Sharp", "id": "234567" } ], "page": { "cursor": "PyEyNXxmMGVmZDA5mOTAw", "next": "https:\/\/api.pinterest.com\/v1\/me\/followers\/?access_token=<YOUR-ACCESS-TOKEN>&cursor=PyEyNXxmMGVmZDA5YmOTAw" } } Please how to get all count from this collection

Thanks,

dirkgroenen commented 9 years ago

Please surround your code with back-thicks makes it a bit more readable..

As for the followers count: you can't get that from the followers endpoint. The counts are located in the User object which can be retrieved through:

$pinterest->users->me(array(
    'fields' => 'username,first_name,last_name,counts'
));

Note the extra field count in the above example. You have to add this otherwise it will return null.

You can also you the find endpoint to retrieve this information for another user:

$pinterest->users->find('dirkgroenen', array(
    'fields' => 'username,first_name,last_name,counts'
));
composercodes commented 9 years ago

@dirkgroenen Thanks very much for help .

Thanks,

khalilrehman36 commented 6 years ago

Hi, I am getting error while trying to create board using "dirkgroenen/Pinterest-API-PHP".

the error is. PinterestException in Request.php line 227: Pinterest error (code: 401) with message: Authorization failed.

My code to create board is. $pinterest->boards->create(array( "name" => "Test board from API", "description" => "Test Board From API Test" ));

whereas I can get user information etc but problem is with post request.

Can you please help me in this regards. Thanks in advance