• Home
  • About
  • Services
    • Technical SEO
    • Local SEO Services
  • Tools
    • Redirects Generator
    • HREFLANG Tag Generator
    • XML Sitemap Generator
    • XML Sitemap URL Extractor
    • Robots.txt Generator
    • Random URL Generator
    • Meta Robots Tag Generator
    • Organization Schema Generator
    • Article Schema Generator
    • Product Schema Generator
    • Local Business Schema Generator
    • FAQPage Schema Generator
    • WordPress Metabox Generator
    • Plugins & Scripts
  • Tutorials Hub
    • Technical SEO
    • WordPress
    • PHP
    • JavaScript
    • Python
    • Google Tag Manager
    • Shopify
    • Other Guides & Tutorials
    • General Discussion
    • View All
  • Contact
    • Hub
      New posts Search forums
    • What's new
      New posts New profile posts Latest activity
    • Members
      Current visitors New profile posts Search profile posts
    Log in Register
    What's new Search

    Search

    By:
    Advanced search…
    • New posts
    • Search forums
    Menu
    Log in

    Register

    Install the app
    • Home
      • Hub
      • Python Scripts & Tutorials
      You are using an out of date browser. It may not display this or other websites correctly.
      You should upgrade or use an alternative browser.

      Xenforo API - Python: Create new Thread

      • Thread starter Chris
      • Start date Oct 6, 2022
      C

      Chris

      Administrator
      Staff member
      • Oct 6, 2022
      • #1
      If you are using the Xenforo community forum script and starting to learn the Xenforo Rest API. This post is to show you how you can programmatically create a new thread with this simple Python script.

      Code:
      # Xenforo Forum - Programmatic Create new Thread
      import requests
      
      # Send API header request
      headers = {
                'Content-type' : 'application/x-www-form-urlencoded',
                 'XF-Api-User': '1',
                'XF-Api-Key' : 'api-key-goes-here'
                }
      
      # Connect with the API Endpoint
      url = 'https://example.com/api/threads/
      
      # Post new thread title & message
      data = {
          'node_id': 23, # node ID is the forum ID
          'title': 'This is the thread title',
          'message': 'This is the thread message body contents This is the thread message body contents.'
      }
      
      r = requests.post(url, headers=headers, data=data)
      
      # Print the response (200 is success)
      print(r)
       
      You must log in or register to reply here.
      Share:
      Facebook Twitter Reddit Pinterest Tumblr WhatsApp Email Share Link

      New Posts

      • C
        add a number to the next column of data, increasing the number as the datapoint changes, and count how many times each datapoint appears
        • Started by Chris
        • Jul 20, 2023
        • Replies: 0
        Other Plugins & Tutorials
      • C
        How to connect to GPT-4 API with Node.js using PowerShell
        • Started by Chris
        • Jul 14, 2023
        • Replies: 0
        JavaScript Scripts & Snippets
      • C
        Google Search Results Scraper - Node JS & Puppeteer
        • Started by Chris
        • Jul 2, 2023
        • Replies: 0
        JavaScript Scripts & Snippets
      • C
        Detect unused JavaScript and CSS in Bulk
        • Started by Chris
        • Jun 29, 2023
        • Replies: 0
        JavaScript Scripts & Snippets
      • C
        Google Sheets Apps Script to Generate Hreflang tags
        • Started by Chris
        • Jun 12, 2023
        • Replies: 0
        Technical SEO
      • C
        Deploying Noindex Meta Robots Tag with JavaScript with Tag Manager - 2 Methods
        • Started by Chris
        • Jun 9, 2023
        • Replies: 0
        Google Tag Manager Tutorials & Guides
      • C
        Guide to Google Search Operators
        • Started by Chris
        • Jun 9, 2023
        • Replies: 0
        Other Plugins & Tutorials
      • C
        Bookmarklet to inspect and identify images that are not using lazy loading on a webpage
        • Started by Chris
        • Jun 2, 2023
        • Replies: 0
        JavaScript Scripts & Snippets
      • Hub
      • Python Scripts & Tutorials

    Technical SEO Consultant

    Chris Lever - Freelance SEO Consultant Availible for Hire. Specialist in Technical SEO Audits, Strategy and Implementation.

    Need Help?

    • BB Code
    • Cookie Policy
    • Terms of Use
    • Privacy Policy
    • HTML Sitemap

    Learn More

    • About
    • Availability
    • Popular Posts
    • Projects & Scripts
    • Contact

    Get in Touch

    Chris Lever, Manchester, United Kingdom
    hello@chrisleverseo.com
    +44 0161 883 7660

    © 2023 Chris Lever SEO. All rights reserved. Powered by Xenforo | PF

    • This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
      By continuing to use this site, you are consenting to our use of cookies.
      Accept Learn more…