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

createPost not working #17

Open
singhsurma opened this issue Jun 14, 2018 · 0 comments
Open

createPost not working #17

singhsurma opened this issue Jun 14, 2018 · 0 comments

Comments

@singhsurma
Copy link

singhsurma commented Jun 14, 2018

Thanks for nice work! I see your comments that below is not working:

/**
     * createPost
     *
     * NOT WORKING YET
     *
     * @param $bodyText
     * @param $topicId
     * @param $userName
     * @return \stdClass
     */
    public function createPost($bodyText, $topicId, $userName)
    {
        $params = [
          'raw'       => $bodyText,
          'archetype' => 'regular',
          'topic_id'  => $topicId
        ];

        return $this->_postRequest('/posts', [$params], $userName);
    }

I have written short function by using that below function we can reply to any Topic :

public function modified_createPost( $userName, $topicId, $post_number, $bodyText)
  {
    $params = [
      'username'  => $userName,
      'topic_id'  => $topicId,
      'post_number' => $post_number,
       'raw'       => $bodyText,
      'archetype' => 'regular'

    ];

    return $this->_postRequest('/posts', [$params], $userName);
  }

To debug parameters used we can see like : http://DISCOURSE_SITE_URL/t/TOPIC_ID.json for example in my case its : http://localhost:3000//t/14.json

screen shot 2018-06-14 at 2 24 03 pm

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

1 participant