2014-05-25 52 views
0

我试图使用ZF1其余客户与Zend_Rest_Client

$this->restClient = new Zend_Rest_Client('https://myurl.com'); 
$response = $this->restClient->delete('/service/'.$this->uuid.'.json?api_key='.$this->apikey); 

删除资源删除,但我得到一个错误:

Path "/service/v-2149d050-c64b-0131-33b0-1231390c0c78.json?api_key=a-9a136a00-b340-0131-2662-1231390c0c78" is not a valid HTTP path 

网络服务文档简单的说就是用

DELETE https://myurl.com/service/YOUR_UUID.json?api_key=YOUR_API_KEY 

关于如何使用这个类的任何想法?

感谢

+0

“'?'”是HTTP URI中的保留字符,如果要在URI的路径中使用它,则需要对其进行百分比编码。在你的代码中你有*没有*编码它。 – hakre

回答

0
DELETE https://myurl.com/service/YOUR_UUID.json?api_key=YOUR_API_KEY 

也就是说只有路径,而是一个完整的URI。它分解为:

  • 路径:service/YOUR_UUID.json
  • 查询的信息:api_key=YOUR_API_KEY

对于Zend的REST客户端,你需要调用每个每个参数的一个功能,参数不能被命名作为一个标准的HTTP动词:

$client = new Zend_Rest_Client('https://exeample.com'); 
$client->api_key(YOUR_API_KEY); 

$response = $client->restClient->delete('/service/'.$this->uuid.'.json); 

欲了解更多信息,请参阅如何传递参数符合你的要求the Request Arguments section in the vendor documentation

+0

也看到:http://stackoverflow.com/q/4725471/367456 – hakre

+0

我试过这种方式,但我得到这个: 错误:simplexml_load_string():^ – user3174311

+0

@ user3174311:恭喜,你已经解决了没有得到* “路径XXX不是有效的HTTP路径”*错误不再。那正是你问到的,不是吗? – hakre