[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 375
  • Last Modified:

How do I Post with cURL?

Hello dear expert-exchange expers,

I am trying to do something with cURL and php. I will shortly tell you what my script does.

Script can login to destination with cookie
Script can fill the form datas on destination
Script cannot submit the form because of javascript.

The code on the destination is below ;

Can someone tell me how can I do post action with curl ?

Any help would be really appreciated. Thanks
<span id="subButton" class="jsButton"><span class="first-child">
		<a href="javascript:document.storyForm.submit();">Publish</a>
//////////////////////////////////////// and for action is ///////////////////////////////////////
<form enctype="multipart/form-data" method="post" action="/post/url/" name="storyForm">

Open in new window

3 Solutions
If you are using Firefox, I highly recommend the addon "Tamper Data"
This allows you to see POST and GET info, as well as destination, User Agents, Hosts, Cookies etc. etc.

Post action with cURL as follows, just remember to change the post fields to match that of the site you want to POST to:

curl_setopt($ch, CURLOPT_POST, 1);		
curl_setopt($ch, CURLOPT_POSTFIELDS, "username=USERNAME&password=PASSWORD&rememberme=TRUE");

Open in new window

LordoftheDreamerAuthor Commented:
Hello dear expersts,

Thank you for your comments.


I took a look that web site. I couldn't figure it out how would I configure that to my script.


I am using Live Http Header which is like Tamper Data but it does not show the post action. The problem is that I am trying to post javascript.

The javasciprt submit code like ;

You could see javascript action on first message.

I would be really so glad if someone help me out.

Thanks anyway who tried to help me.

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

cURL cannot interpret Javascript on it's own, but if you know what the Javascript is doing, you can probably work around it.

Try installing tamper data and submitting the form like you usually do manually. See what is being POSTed and where to. Then you can simply use the cURL code I gave you above to bypass the javascript and continue like normal
LordoftheDreamerAuthor Commented:
Mr. Daniel I could pay for this help. Could you let me know how can I contact to you ?
Is that allowed?
If so post your email address here, and I'll contact you by email. I'll then help you over MSN messenger or something.
LordoftheDreamerAuthor Commented:
I do not know it is allowed or not but I need this help. My msn messenger ID lordofthedreamer@live.com
I think you need a wrapper around cURL.  Like suggested using php or perl or even shellscript.  Sounds like other user is helping you.  Thought I throw that in anyway.
LordoftheDreamerAuthor Commented:
Thank you everybody who tried to help me. If someone would like to talk about cURL do not hesitate to add to me your contact list.

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now