2016-04-01 22 views
0

PHP örnek snippet'ini (Marketo doc page 0 Update Landing Page Template Content by Id) REST API URL'sini, client_id, client_secret ve basit bir şablon dosyası ile değiştirmeyi denedim. Sonuç olarak bool (false) üretir. Ben biraz farklı equivelent kullanılan Marketo REST API - Güncelleştirme Sayfası Şablonları - Sistem hatası 611

buldum ki ... nesne benim DİNLENME çağrı sonuçları (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)" Sistem hatası "}}}

Gizemli hata kodu 611'den ne haber -" sistem hatası "yeterince yardımcı olmadığından ne anlama geliyor? biliyorum - bu durumda neden oluyor?

Açılış sayfası şablonlarını güncelleştirmek için bu REST API'sı gerçekten çalışıyor mu?

<?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

olması gerekiyordu, C# bir cazibe gibi çalışır pasajı. – starlocke

+0

Tam bir isteğin müşteri kimliğinizle nasıl göründüğünü ve gizliliğin nasıl düzeltildiğini gösterir misiniz? – kelkington

cevap

0

Sadece bir dosya yolunu sağlamada basit bir programlama yaptım.

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

İlginçtir ki

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