bstoilov / py3-pinterest

Fully fledged Python Pinterest client
MIT License
310 stars 106 forks source link

Pinterest.pin() got an unexpected keyword argument 'image_path' #209

Open 9-shen opened 2 months ago

9-shen commented 2 months ago

from datetime import datetime from py3pin.Pinterest import Pinterest import config

EMAIL = config.EMAIL PASSWORD = config.PASSWORD USERNAME = config.USERNAME CRED_ROOT = "cred_root"

BOARD_NAME = 'Morocco' IMAGE_PATH = 'Images/morocco.jpg'
PIN_DESCRIPTION = 'Discover the beauty of Morocco!' PIN_TITLE = 'Morocco' PIN_LINK = 'https://example.com/morocco-tour'

def get_board_id(pinterest, username, board_name): boards = pinterest.boards(username=username) for board in boards: if board['name'].lower() == board_name.lower(): return board['id'] return None

def upload_pin(): pinterest = Pinterest(email=EMAIL, password=PASSWORD, username=USERNAME, cred_root=CRED_ROOT) pinterest.login()

board_id = get_board_id(pinterest, USERNAME, BOARD_NAME)

if not board_id:
    print(f"Board '{BOARD_NAME}' not found.")
    return

response = pinterest.pin(
    board_id=board_id,
    image_path='IMAGE_PATH',  
    description=PIN_DESCRIPTION,
    title=PIN_TITLE,
    link=PIN_LINK
)

if response and 'id' in response:
    pin_id = response['id']
    print(f"Pin created successfully! Pin ID: {pin_id}")
else:
    print("Failed to create the pin.")

if name == 'main': upload_pin()

I got an error that unexpected keyword ( image_path )? can you help me please ?

runcode1 commented 2 months ago

upload_pin

If you use upload_pin, the image parameter is image_file, if you use pin, the image parameter is image_url