WordPress.org

Ready to get started?Download WordPress

Forums

JSON API
Creating a post from a different domain (1 post)

  1. wprocks
    Member
    Posted 2 years ago #

    Hi all,

    I was trying to create a post from a different domain and i receive the error :

    {
         status: "error",
          error: "You need to login with a user capable of creating posts."
    }

    I was trying to create the post by using the following api call:

    $post_json_api = http://localhost/public_html/samplewebsite/samplewebsite/?json=posts/create_post&dev=1&nonce=f7da829154&tags=Photos%20for%20&title=sd%20sd%20sd&content=<p>testing testing</p>&callback=do_thing

    The "sample" website is the wordpress website.

    I called the above url by doing this in PHP:

    $json_api_response = file_get_contents($post_json_api,0,null,null);

    I've included the callback_back argument as well, but still receiving the error.

    The nonce value is correct and the weird thing is when copy and paste the $post_json_api URL into the browser, it actually works. But it doesnt work when i try to call the URL from another ( localhost ) location.

    Any idea on how to make this work ?

    Thanks!

    http://wordpress.org/extend/plugins/json-api/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic