-2

PHP curl を使用して、php アプリケーションから basecamp にメッセージを投稿しようとしています。このコードを実行すると、次のようなエラーが返されます

Hmm, that isn’t right
You may have typed the URL incorrectly.
Check to make sure you’ve got the spelling, capitalization, etc. exactly right.

コード

<?php

$username = 'username';
$password = 'password';
$datastring = json_encode(array("name" => "from cURL"));

$URL = "https://basecamp.com/***/api/v1/projects/****.json";

   $ch = curl_init($URL);
   curl_setopt($ch, CURLOPT_MUTE, 1);
   curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
   curl_setopt($ch, CURLOPT_POST, 1);
   curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
   //curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
   curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json; charset=utf-8'));
   curl_setopt($ch, CURLOPT_POSTFIELDS, $datastring);
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   $output = curl_exec($ch);
   curl_close($ch);
 echo $output;
?>

API URL が正しいかどうかわかりませんか? どのように解決できますか?

4

1 に答える 1

0

URL が正しくないようです - https://github.com/basecamp/bcx-api/blob/master/sections/messages.md#create-messageおよびhttps://github.com/を確認してください。メッセージまたはコメントを追加するための basecamp/bcx-api/blob/master/sections/comments.md#create- comment。

プロジェクトに新しいメッセージを追加するには、

$URL = "https://basecamp.com/***/api/v1/projects/****/messages.json";
于 2014-05-15T08:12:31.223 に答える