Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
9-shen opened this issue Aug 26, 2024 · 1 comment
Open

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

9-shen opened this issue Aug 26, 2024 · 1 comment

Comments

@9-shen
Copy link

9-shen commented Aug 26, 2024

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
Copy link

upload_pin

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants