Coder Social home page Coder Social logo

Comments (8)

nategood avatar nategood commented on July 28, 2024 1

Is the endpoint you are posting to expecting application/x-www-form-urlencoded? What error are you getting back? It looks like you are wrapping your array definition in a string there. The following works if I understand what you're trying to accomplish (the sendsForm is not required by default but I have included it here to be safe).

$response = \Httpful\Request::post($destUrl)
    ->body(array(
        'operation'=> 'login', 
        'username'=> $destUser,
        'accessKey'=> $generatedKey))
    ->sendsForm()
    ->send();

from httpful.

nategood avatar nategood commented on July 28, 2024

Sorry about that. We moved to a versioned based phar naming scheme. You can download the latest version or choose from all versions on the downloads page

from httpful.

rkshakya avatar rkshakya commented on July 28, 2024

Mr Nat,
Thanks for the response.
Could you please kindly inform if I am making POST request wrongly as below:
$response1 = \Httpful\Request::post($destURL)
-> addHeaders(array('operation'=>'login', 'username'=>$destUser,
'accessKey'=>$generatedKey))
->send();

On Fri, Nov 2, 2012 at 8:39 PM, Nate Good [email protected] wrote:

Sorry about that. We moved to a versioned based phar naming scheme. You
can download the latest versionhttps://github.com/downloads/nategood/httpful/httpful-0.2.0.pharor choose from all versions on the downloads
page https://github.com/nategood/httpful/downloads


Reply to this email directly or view it on GitHubhttps://github.com//issues/61#issuecomment-10016826.

Thanks and Regards,
Ravi Kishor Shakya
https://github.com/rkshakya/RKSProjects
http://ravikshakya.blogspot.com

"Start by doing what is necessary, then what is possible and suddenly you
are doing the impossible." -St Francis.

from httpful.

nategood avatar nategood commented on July 28, 2024

Did you intend to use headers or are you attempting to use that data in the
body? If it is the latter, change addHeaders to body. This also
assumes that you are using application form urlencoded as the mime type.
My guess is that is what you want.

On Fri, Nov 2, 2012 at 12:06 PM, Ravi Kishor Shakya <
[email protected]> wrote:

Mr Nat,
Thanks for the response.
Could you please kindly inform if I am making POST request wrongly as
below:
$response1 = \Httpful\Request::post($destURL)
-> addHeaders(array('operation'=>'login', 'username'=>$destUser,
'accessKey'=>$generatedKey))
->send();

On Fri, Nov 2, 2012 at 8:39 PM, Nate Good [email protected]
wrote:

Sorry about that. We moved to a versioned based phar naming scheme. You
can download the latest version<
https://github.com/downloads/nategood/httpful/httpful-0.2.0.phar>or
choose from all versions on the downloads
page https://github.com/nategood/httpful/downloads


Reply to this email directly or view it on GitHub<
https://github.com/nategood/httpful/issues/61#issuecomment-10016826>.

Thanks and Regards,
Ravi Kishor Shakya
https://github.com/rkshakya/RKSProjects
http://ravikshakya.blogspot.com

"Start by doing what is necessary, then what is possible and suddenly you
are doing the impossible." -St Francis.


Reply to this email directly or view it on GitHubhttps://github.com//issues/61#issuecomment-10019336.


Nate Good
Director of Software Engineering
ShowClix, Inc.

Ph: 412.259.5869
Fax: 724.261.5332
http://www.showclix.com

from httpful.

rkshakya avatar rkshakya commented on July 28, 2024

Mr Nate,
I tried both (adding params in body / headers) but seems not working:
$response1 = \Httpful\Request::post($destURL)
->body("array('operation'=>'login', 'username'=>$destUser,
'accessKey'=>$generatedKey)", 'application/x-www-form-urlencoded')
->send();

Could not you please include a good example of POST request in the doc here
http://phphttpclient.com/#post-xml for benefit for many dumb people like me
? :)
Thanks

On Fri, Nov 2, 2012 at 10:07 PM, Nate Good [email protected] wrote:

Did you intend to use headers or are you attempting to use that data in
the
body? If it is the latter, change addHeaders to body. This also
assumes that you are using application form urlencoded as the mime type.
My guess is that is what you want.

On Fri, Nov 2, 2012 at 12:06 PM, Ravi Kishor Shakya <
[email protected]> wrote:

Mr Nat,
Thanks for the response.
Could you please kindly inform if I am making POST request wrongly as
below:
$response1 = \Httpful\Request::post($destURL)
-> addHeaders(array('operation'=>'login', 'username'=>$destUser,
'accessKey'=>$generatedKey))
->send();

On Fri, Nov 2, 2012 at 8:39 PM, Nate Good [email protected]
wrote:

Sorry about that. We moved to a versioned based phar naming scheme.
You
can download the latest version<
https://github.com/downloads/nategood/httpful/httpful-0.2.0.phar>or
choose from all versions on the downloads
page https://github.com/nategood/httpful/downloads


Reply to this email directly or view it on GitHub<
https://github.com/nategood/httpful/issues/61#issuecomment-10016826>.

Thanks and Regards,
Ravi Kishor Shakya
https://github.com/rkshakya/RKSProjects
http://ravikshakya.blogspot.com

"Start by doing what is necessary, then what is possible and suddenly
you
are doing the impossible." -St Francis.


Reply to this email directly or view it on GitHub<
https://github.com/nategood/httpful/issues/61#issuecomment-10019336>.


Nate Good
Director of Software Engineering
ShowClix, Inc.

Ph: 412.259.5869
Fax: 724.261.5332
http://www.showclix.com


Reply to this email directly or view it on GitHubhttps://github.com//issues/61#issuecomment-10019882.

Thanks and Regards,
Ravi Kishor Shakya
https://github.com/rkshakya/RKSProjects
http://ravikshakya.blogspot.com

"Start by doing what is necessary, then what is possible and suddenly you
are doing the impossible." -St Francis.

from httpful.

rkshakya avatar rkshakya commented on July 28, 2024

This works! apparently sendForm is required
Thanks a lot.

On Fri, Nov 2, 2012 at 11:14 PM, Nate Good [email protected] wrote:

Is the endpoint you are posting to expecting
application/x-www-form-urlencoded? What error are you getting back? It
looks like you are wrapping your array definition in a string there. The
following works if I understand what you're trying to accomplish (the
sendsForm is not required by default but I have included it here to be
safe).

$response = \Httpful\Request::post($destUrl)
->body(array(

    'operation'=> 'login',
    'username'=> $destUser,
    'accessKey'=> $generatedKey))

->sendsForm()
->send();


Reply to this email directly or view it on GitHubhttps://github.com//issues/61#issuecomment-10022262.

Thanks and Regards,
Ravi Kishor Shakya
https://github.com/rkshakya/RKSProjects
http://ravikshakya.blogspot.com

"Start by doing what is necessary, then what is possible and suddenly you
are doing the impossible." -St Francis.

from httpful.

rkshakya avatar rkshakya commented on July 28, 2024

Mr Nate,
I was trying to make POST request as
$objectJson = json_encode($contactData);
$response = \Httpful\Request::post($destURL)
->body(array("sessionName"=>$sessionId,
"operation"=>'create',
"element"=>$objectJson,
"elementType"=>$moduleName))
->send();

and it fails. I tried these as well:
$objectJson = json_encode($contactData);
$response = \Httpful\Request::post($destURL)
->body(array("sessionName"=>$sessionId,
"operation"=>'create',
"element"=>$objectJson,
"elementType"=>$moduleName))
-> sendsForm()
->send();

and using smartSerializePayload() as $objectJson is complex object type
$objectJson = json_encode($contactData);
$response = \Httpful\Request::post($destURL)
->body(array("sessionName"=>$sessionId,
"operation"=>'create',
"element"=>$objectJson,
"elementType"=>$moduleName))
->smartSerializePayload( )
->send();

but it also did not work.
Could you please tell me what I am doing wrong?
I tried to go through the HTTPful API docs, but that was too technical.
Thanks

On Fri, Nov 2, 2012 at 11:20 PM, Ravi Kishor Shakya(रवि किशोर शाक्य) <
[email protected]> wrote:

This works! apparently sendForm is required
Thanks a lot.

On Fri, Nov 2, 2012 at 11:14 PM, Nate Good [email protected]:

Is the endpoint you are posting to expecting
application/x-www-form-urlencoded? What error are you getting back? It
looks like you are wrapping your array definition in a string there. The
following works if I understand what you're trying to accomplish (the
sendsForm is not required by default but I have included it here to be
safe).

$response = \Httpful\Request::post($destUrl)
->body(array(

    'operation'=> 'login',
    'username'=> $destUser,
    'accessKey'=> $generatedKey))

->sendsForm()
->send();


Reply to this email directly or view it on GitHubhttps://github.com//issues/61#issuecomment-10022262.

Thanks and Regards,
Ravi Kishor Shakya
https://github.com/rkshakya/RKSProjects
http://ravikshakya.blogspot.com

"Start by doing what is necessary, then what is possible and suddenly you
are doing the impossible." -St Francis.

Thanks and Regards,
Ravi Kishor Shakya
https://github.com/rkshakya/RKSProjects
http://ravikshakya.blogspot.com

"Start by doing what is necessary, then what is possible and suddenly you
are doing the impossible." -St Francis.

from httpful.

frankred avatar frankred commented on July 28, 2024

Would be great to have this essential request on the "example"-page. I nearly searched more than an hour for an easy POST with PARAMS request unti I found this thread 👍

from httpful.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.