PHP,jira中curl_exec($ ch)时的错误 - >试图获取非对象的属性

时间:2017-04-04 09:39:19

标签: php curl jira

当我执行此代码时,我得到一个null对象,我没有发现它的错误。

 $data = array(
"fields" => array(
    "project" => array(
        "key" => "ISSGS"
    ),
    "summary" => "Try",
    "description" => "Try2",
    "assignee"=>array("name"=>"myName"),
    "issuetype" => array(
        "name" => "Proyect"
    ),
    "customfield_10490"=>array("value"=>"INEKN")
)

);

function post_to($data) {

$ch = curl_init();

$headers = array('Accept: application/json', 'Content-Type: application/JSON');

curl_setopt_array($ch, array(
    CURLOPT_POST => TRUE,
    CURLOPT_URL => URL_JIRA,
    CURLOPT_USERPWD => $username . ':' . $password,
    CURLOPT_POSTFIELDS => $jdata,
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_SSL_VERIFYPEER => false
));
$result = curl_exec($ch);
return json_encode($result);
}

$result = post_to($data);

if (property_exists($result, 'errors')) {
    echo "Error(s) creating issue:\n";
 }else {
    echo "New issue created at " . URL_JIRA . "{$result->key}\n";
 }

不是URL或用户名/传递问题,问题是函数post_to()返回NULL。

0 个答案:

没有答案