0

The Zend_Http_Client docs are confusing and hard to understand. Currently I am using the following code to GET information from the Challonge API:

$client = new Zend_Http_Client("https://api.challonge.com/v1/tournaments/$bracket.json"); $client->setParameterGet(array( 'api_key' => $apikey, 'include_participants' => 1, )); $feed = $client->request()->getBody(); 

Very simple, three lines. Now this is a GET. How would I do the same exact thing as a PUT? Passing parameters and everything. What about a DELETE?

2 Answers 2

3

Sorry, I know this is not directly related to the question Json Axelrod asked, but I had a similar problem and could not find the solution anywhere online.

I was trying to do a PUT / DELETE request with Magentos Varien_Http_Client

class Varien_Http_Client extends Zend_Http_Client

So I thought the same would apply that was written in this topic and here. However no matter what I tried I could not get PUT nor DELETE requests to work.

Really simple solution in that case: Use Zend_Http_Client instead of Varien_Http_Client. It seems that Magentos Http Client class is adding some extra "convenient" methods for preparing the body that won't allow PUT nor DELETE requests.

Sign up to request clarification or add additional context in comments.

2 Comments

@MrSnoozies gotta love those "features". this one just made me lose two hours
@GabrielQueirozSilva Same here, except lost quite a log more hours. What is the point of making own shitty wrapper around a perfectly good framework?
0

You would do

$client->request('POST') 

or

$client->request('DELETE') 

4 Comments

Ah... so its as simple as adding a parameter inside of the request? And it defaults to GET, which is why I never needed it before? What about setParameterGet? Would I replace that with setParameterPut? Or is there a different way to do it?
It would be setParameterPost for POST
The API says it has to be a PUT, not POST... are they interchangeable?
You have to set raw data. framework.zend.com/apidoc/1.7/Zend_Http/Client/…. It has only convenience methods for GET and POST

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.