Skip to content

Add support for cross posting #7

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/RedditAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,37 @@ public function submitLinkPost($subreddit, $title, $url, $send_replies = true, $

return $response;
}

/**
* Submits a cross post.
*
* @param string $subreddit Subreddit in which to post.
* @param string $title Title of post.
* @param string $crosspost_fullname Name of original post.
* @param bool $send_replies Send comment replies to the current user's inbox. True to enable, false to disable.
* @param bool $distinguish Whether or not it should be mod distinguished (for modded subreddits only).
*
* @return object Response to API call.
*/
public function submitCrossPost($subreddit, $title, $crosspost_fullname, $send_replies = true, $distinguish = false)
{
$params = [
'api_type' => 'json',
'extension' => 'json',
'kind' => 'crosspost',
'resubmit' => 'true',
'sendreplies' => ($send_replies) ? 'true' : 'false',
'sr' => $subreddit,
'title' => $title,
'crosspost_fullname' => $crosspost_fullname
];
$response = $this->apiCall('/api/submit', 'POST', $params);
if ($distinguish && isset($response->json->data->name)) {
$this->distinguish($response->json->data->name, true);
}

return $response;
}

/**
* Submits a new text post.
Expand Down