I am following the instructions at https://api.slack.com/messaging/retrieving#getting_started to retrieve Slack messages using PHP and cURL. I can list my channels ok but trying to retrieve messages generates an error {"ok":false,"error":"not_in_channel"}. This error is not listed on the method page at https://api.slack.com/methods/conversations.history#response so I am puzzled as to what is wrong.
//Initialize cURL.
$ch = curl_init();
//Set the URL that you want to GET by using the CURLOPT_URL option.
curl_setopt($ch, CURLOPT_URL, 'https://slack.com/api/conversations.history');
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: Bearer xoxb-mykeyishereinmycode'
));
//Set CURLOPT_RETURNTRANSFER so that the content is returned as a variable.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//Set CURLOPT_FOLLOWLOCATION to true to follow redirects.
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
//Set CURL Data
$fields = array(
'channel' => 'C041N9P069J'
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
//Execute the request.
$data = curl_exec($ch);
//Close the cURL handle.
curl_close($ch);
print_r($data);