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

/me/pins not returning full data from pinterest #9

Closed nWidart closed 8 years ago

nWidart commented 8 years ago

Hello,

The pinterest->users->getMePins() and the pinterest->pins->get($pinId) aren't returning the full data from the pinterest API. If I browse to the endpoint in browser, to the corresponding endpoint, I get more data back than the returned data in code.

Ie: in browser:

{
"attribution": null,
"creator": {
"url": "https://www.pinterest.com/nwidart/",
"first_name": "Nicolas",
"last_name": "Widart",
"id": "100979354053381714"
},
"url": "https://www.pinterest.com/pin/100979216618556872/",
"media": {
"type": "image"
},
"created_at": "2013-10-20T21:06:13",
"original_link": "http://www.corbiau.com/#houses",
"note": "Marc Corbiau | Uccle, Belgium, 2003",
"color": "#a9a6a4",
"link": "https://www.pinterest.com/r/pin/100979216618556872/4803529652880556599/6889b6ebba2030e5f0fd96acaaca324e402fc43ce2ba2e36f1738eba30c656bd",
"board": {
"url": "https://www.pinterest.com/nwidart/minimal-interiors-inspiration/",
"id": "100979285333932411",
"name": "Minimal interiors inspiration"
},
"counts": {
"likes": 0,
"comments": 0,
"repins": 0
},
"id": "100979216618556872",
"metadata": {}
},

Using the package:

"url" => "https://www.pinterest.com/pin/100979216618556872/"
    "note" => "Marc Corbiau | Uccle, Belgium, 2003"
    "link" => "https://www.pinterest.com/r/pin/100979216618556872/4803529652880556599/6889b6ebba2030e5f0fd96acaaca324e402fc43ce2ba2e36f1738eba30c656bd"
    "id" => "100979216618556872"

Did I miss something ?

Thanks

dirkgroenen commented 8 years ago

Pinterest only returns a limited set of data. If you want more you can specify this through the data parameter in the API request.

Though, looking at your response the above wouldn't be correct. I've just checked the API endpoint through the API explorer and it returns a limited set of attributes (which would make the above true again). How does the url you're requesting look like? Mine was:

https://api.pinterest.com/v1/me/pins/?access_token=[xxx]
nWidart commented 8 years ago

Oh correct, the url has indeed an additional fields parameter

v1/me/pins/?access_token=TOKEN&fields=id%2Clink%2Cnote%2Curl%2Ccounts

I see it is even documented on the readme!

Running the following now returns everything:

$this->pinterest->users->getMePins(['fields' => 'created_at,link,creator,board,note,color,counts,media,attribution,image,metadata']);

Sorry for the trouble!

Thank you for the explanation. :smile: