Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1100171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:50:28+00:00 2026-05-17T00:50:28+00:00

I am trying to post to a REST service using PHP cURL but I’m

  • 0

I am trying to post to a REST service using PHP cURL but I’m after running into a bit of difficulty (this being that I’ve never used cURL before!!).

I’ve put together this code:

  <?php
error_reporting(E_ALL);
if ($result == "00")
{

$url = 'http://127.0.0.1/xxxxxx/AccountCreator.ashx'; /*I've tried it a combination of ways just to see which might work */

$curl_post_data = array(
    'companyName' =>urlencode($companyName),
    'mainContact' =>urlencode($mainContact),
    'telephone1' =>urlencode($telephone1),
    'email' => urlencode($email),
    'contact2' => urlencode($contact2),
    'telephone2' => urlencode($telephone2)
    'email2' => urlencode($email2);
    'package' => urlencode($package)
    );

foreach($curl_post_data as $key=>$value) {$fields_string .=$key. '=' .$value.'&';
}
rtrim($fields_string, '&');
die("Test: ".$fields_string);

$ch = curl_init();

curl_setopt ($ch, CURLOPT, $url);
curl_setopt ($ch, CURLOPT_POST, count($curl_post_data));
curl_setopt ($ch, CURLOPT_POSTFIELDS, $fields_string);

$result = curl_exec($ch);

curl_close($ch);

Following this, my code sends an email and performs an IF statement. I know this works okay, I only started running into trouble when I tried to insert this cURL request.

I’ve tried this however it doesn’t run. As I am integrating with payment partners, it just says:

Your transaction has been successful but there was a problem connecting back to the merchant's web site. Please contact the merchant and advise them that you received this error message. Thank you.

The exact error that was received was a HTTP 500 error.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T00:50:29+00:00Added an answer on May 17, 2026 at 12:50 am
    foreach($curl_post_data as $key=>value) {$fields_string .=$key. '=' .value.'&';
    

    value here is missing a dollar i guess

    foreach($curl_post_data as $key => $value) {$fields_string .=$key. '=' .$value.'&';
    

    have you tried die($fields_string); to see what are you actually sending to the merchant?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to post some JSON to a rest service using Apache Httpclient.
Using REST Server 6.x-2.0-beta3, I'm trying to understand how to post to user.save. curl
I'm trying to POST to a REST service using the default WebHttpBinding binding. The
I'm trying to comunicate with my rest service but this one return always that
I have been trying to post using RestKit after I have successfully used it
I'm trying to create a REST service defined as: @POST @Path(/path) @Consumes(MediaType.APPLICATION_XML) @Produces(multipart/mixed) public
I am trying to post a request to a REST service (HP ALM 11
I am trying to post data to WCF REST service and I keep getting
I am trying to write a short Rest Service with Zend Framework. But the
I am trying to create a logging service using WCF Rest. It looks something

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.