2016-04-01 47 views
0

我試圖使用替代我的REST API URL,client_id,client_secret和簡單模板文件的(示例代碼片段:) Update Landing Page Template Content by Id上的PHP示例片段。它僅產生bool(false)Marketo REST API - 更新登陸頁面模板 - 系統錯誤611

當我使用稍微不同的equivelent時,我發現我的REST調用導致... object(stdClass)#3(3){[「requestId」] => string(16)「e714#153c7bf644f」 [「success」] => bool(false)[「errors」] => array(1){[0] => object(stdClass)#4(2){[「code」] => string(3)「 611「[」message「] => string(12)」System error「}}}

神祕的錯誤代碼611是什麼 - 它究竟是什麼意思,因爲」系統錯誤「沒有足夠的幫助知道 - 爲什麼在這種情況下發生?

此REST API更新着陸頁模板實際上是否仍然有效?

<?php 
/* 
    Some other functions that made use of $lp_template_id are up here 
*/ 

$landingPageTemplate = new UpdateLandingPageTemplateContent(); 
$landingPageTemplate->id = 1234; 
$landingPageTemplate->content = new CURLFile("/path_to_my_template/{$lp_template_id}", "text/html", "content"); 
print_r($landingPageTemplate->postData()); 

class UpdateLandingPageTemplateContent{ 
    private $host = "https://xxx-xxx-xxx.mktorest.com"; 
    private $clientId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; 
    private $clientSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; 
    public $id;//id of the teplate to update 
    public $content; //HTML content of Template, required 

    public function postData(){ 
     $url = $this->host . "/rest/asset/v1/landingPageTemplate/" . $this->id . "/content.json?access_token=" . $this->getToken(); 
     $ch = curl_init($url); 
     $requestBody = array("content" => $this->content); 
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
     curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json','Content-Type: multipart/form-data')); 
     curl_setopt($ch, CURLOPT_POST, 1); 
     curl_setopt($ch, CURLOPT_POSTFIELDS, $requestBody); 
     curl_getinfo($ch); 
     $response = curl_exec($ch); 
     return $response; 
    } 

    private function getToken(){ 
     $ch = curl_init($this->host . "/identity/oauth/token?grant_type=client_credentials&client_id=" . $this->clientId . "&client_secret=" . $this->clientSecret); 
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
     curl_setopt($ch, CURLOPT_HTTPHEADER, array('accept: application/json',)); 
     $response = json_decode(curl_exec($ch)); 
     curl_close($ch); 
     $token = $response->access_token; 
     return $token; 
    } 

} 
+0

有趣的是,C#代碼片段就像一個魅力的作品。 – starlocke

+0

您能否顯示完整請求與您的客戶端ID和祕密編輯的內容相似? – kelkington

回答

0

我只是做了一個簡單的編程來提供文件的路徑。

$landingPageTemplate->content = new CURLFile("/path_to_my_template/{$lp_template_id}", "text/html", "content"); 

應該是

$landingPageTemplate->content = new CURLFile("/path_to_my_template/{$landingPageTemplate->id}", "text/html", "content");