我想知道是否有訪問一個巨大的字符串我有信息的簡單方法,該字符串的結構,爲人們進行檢討的目的,我把換行符和空間,但這個文本只是一個巨大的單一生產線的返回:在PHP從吉拉Atlassian的問題URL格式長結構化文本字符串
首先這是我訪問吉拉API:
$username = 'xxx';
$password = 'xxx';
$url = 'https://xxx.atlassian.net/rest/api/2/Issue/Bug-5555';
$curl = curl_init();
curl_setopt($curl, CURLOPT_USERPWD, "$username:$password");
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
$issue_list = (curl_exec($curl));
echo $issue_list;
現在返回一個巨大的字符串,當分解如下:
{"expand":
"renderedFields,names,schema,transitions,operations,editmeta,changelog",
"id":"16935",
"self":"https://xxx.atlassian.net/rest/api/2/issue/16935",
"key":"xx-5555",
"fields":
{"summary":"Dialog boxes shouldn't be on top.",
"progress":
{"progress":0,
"total":0
},
"timetracking":{},
"issuetype":
{"self":"https://xxx.atlassian.net/rest/api/2/issuetype/1",
"id":"1",
"description":"A problem which impairs or prevents the functions of the product.",
"iconUrl":"https://xxx.atlassian.net/images/icons/bug.gif",
"name":"Bug",
"subtask":false
},
"timespent":null,
"reporter":
{"self":"https://xxx.atlassian.net/rest/api/2/user?username=xxx%40xxx.com",
"name":"[email protected]",
"emailAddress":"[email protected]",
"avatarUrls":{"16x16":"https://xxx.atlassian.net/secure/useravatar?size=small&avatarId=10122",
"48x48":"https://xxx.atlassian.net/secure/useravatar?avatarId=10122"},
"displayName":"xxx",
"active":true
},
"created":"2012-08-25T18:39:27.760-0600",
"updated":"2012-08-31T16:47:38.761-0600",
"priority":
{"self":"https://xxx.atlassian.net/rest/api/2/priority/6",
"iconUrl":"http://dl.dropbox.com/u/xxx/3-green.png",
"name":"3 - Medium Priority",
"id":"6"
},
"description":"\"loading \" dialog is always on top, so is the \"Updating database\" dialog.\r\n\r\n\r\nThis is annoying. It shouldn't be on top and/or you should be able to easily minimize the window.",
"issuelinks":[], etc etc etc
現在我是一個基本的PHP用戶,所以請儘量保持答覆簡單,如果可能的話,我纔下去解析整個文件的路徑,這將是我很難作爲即時通訊不熟悉解析我在想,如果有一個簡單的方法來訪問值。
什麼IM的想法是這樣的:
foreach($issue_list->issues as $issue) {
echo "summary" . $issue->summary;
echo "updated" . $issue->updated;
echo "created" . $issue->created;
echo "description" . $issue->description;
}
現在,這可能是一廂情願的想法,但我看到的一篇文章,其中我的人做類似的東西,但我不能弄明白,這裏是文章: http://www.lornajane.net/posts/2012/using-jiras-rest-api-to-create-a-dashboard
此外,如果可能的話,如何將我訪問的記者>顯示名稱值,因爲這是兩個縮進深,這將是$發出─>報道子 - >顯示名;
最後一個快速的其他問題,如果即時消息回顯描述,我如何得到它服從/ r/r/r/r/r/n和/「因此它用換行符打印出來並刪除它們特殊字符
感謝Mate正是我所需要的,所以很高興我可以通過這種方式獲取信息,應該節省大量的工作,這就是工作原理: $ issue_list = curl_exec($ curl); $ issue_json = json_decode($ issue_list); 回顯「描述」。 $ issue_json->板塊 - >描述; – user1547410
現在是時候把所有這些問題都標記爲「無法重現」或「無法修復」;)很高興能夠提供幫助! – emartel