php jira,php – 为Jira的api添加附件
我正在嘗試使用他們的API將文件附加到Jira案例.我在Drupal 6(
PHP v.5.0)中這樣做.這是我的代碼:
$ch = curl_init();
$header = array(
'Content-Type: multipart/form-data',
'X-Atlassian-Token: no-check'
);
$attachmentPath = $this->get_file_uploads();
//$attachmentPath comes out to be something like:
//http://localhost/mySite/web/system/files/my_folder/DSC_0344_3.JPG
$data = array('file'=>"@". $attachmentPath, 'filename'=>'test.png');
$url= 'https://mysite.atlassian.net/rest/api/2/issue/20612/attachments/';
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, $this->get_jira_headers());
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS ,$data);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERPWD, "myusername:mypassword");
$result = curl_exec($ch);
$ch_error = curl_error($ch);
問題是$result表示為false,$ch_error表示無法打開文件.這個錯誤是否與Drupal有關或與我如何向Jira發送請求有關?順便說一句,如果我使用絕對路徑,但是,像這樣:
$attachmentPath = 'C:\wamp\www\mySite\web\sites\mySite.net\files\my_folder\DSC_0333.JPG';
上傳工作正常.
總結
以上是生活随笔為你收集整理的php jira,php – 为Jira的api添加附件的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php gd库画线,[PHP] GD库(
- 下一篇: matlab 凹盘,刹车盘凹槽是怎么形成