GithubHelp home page GithubHelp logo

Comments (5)

bstoilov avatar bstoilov commented on May 30, 2024 1

Thank you very much Gmanicus, we should add these to the documentation.

from py3-pinterest.

Gmanicus avatar Gmanicus commented on May 30, 2024 1

Yw. Created PR #43

from py3-pinterest.

bstoilov avatar bstoilov commented on May 30, 2024

Good suggestion. The examples should be updated too.
The create board actually returns the full response object

return self.post(url=CREATE_BOARD_RESOURCE, data=data)

Initially I had custom object that contained only the meaningful information from the responses, but it was hard to maintain

from py3-pinterest.

Gmanicus avatar Gmanicus commented on May 30, 2024

Turns out all your functions were set that way and no changes need to be made! Printing the response directly shows something like <Response 200>. If you dig a little deeper by going myresponse.content you get the actual HTML response, which can then be turned into a dict by using JSON.

Example:

import json

pin = upload_pin(board_id="778489554276995995",
             image_path="test.png",
             description="TESTING PIN FUNCTIONALITY WITH LINK",
             title="Foobar Barfood",
             section_id=None,
             link="www.geekoverdrivestudio.com")

pin_response = json.loads(pin.content)

Some helpful notes on the response:
Everything is stored inside the "resource_response" key. You can use that and grab all sorts of data like so:

id = pin_response["resource_response"]["id"]
# When creating such a resource, and you want to see details for what it was created IN,
# you just have to go one further step and access the key for whatever it is: section, board, pinner, etc
board_id = pin_response["resource_response"]["board"]["id"]
# Section will return None/Null if the pin wasn't placed within a section
section_id = pin_response["resource_response"]["section"]["id"]
pinner_username = pin_response["resource_response"]["pinner"]["username"]
pinner_id = pin_response["resource_response"]["pinner"]["id"]

from py3-pinterest.

Gmanicus avatar Gmanicus commented on May 30, 2024

Another note upon further use of this method:

Section and Board IDs are one step further down the dict. It may be the same for Pins too.

id = response["resource_response"]["data"]["id"]

from py3-pinterest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.