Jump Page with CURL Option

Status
Not open for further replies.

mamamia

New Member
After a whole lot of trial and error, I think I've finally gotten my CURL script to work properly and POST parameters to the Jump page specified. Just one issue now....

The Jump page is shown within my existing Joomla site. In other words, the template is kept intact (i.e. header, menus, etc.) and the main content area is populated with the Jump page. However, my Jump page is an external site and I want the browser to redirect the whole browser session. How can I do this?

Thanks in advance.
mamamia
 
Ok so apparently there is one other issue....

No email is sent by Fabrik when I use the CURL functionality. I have the "process CURL script" set to "After fabrik has processed the form". Why is no email being sent. If I turn off CURL then I receive the email just fine.

mamamia
 
Can we get one of the Fabrik developers try BOTH of these issues to confirm them as a bugs, so that they can be fixed as soon as possible if they are in fact bugs. Thanks.

mamamia
 
to redirect to a new page with php use:
header('Location: http://www.example.com/');

http://php.net/header

Can you post your curl script and jump page so that I can test this issue? Looking at the code the emails certainly should be sent before the curl php script is run

Are the emails sent if you dont process the curl script?

Cheers
Rob
 
Here is what my CURL code looks like. Obviously I am not using what you mentioned to redirect, but now I'm wondering how much of this is valid at all. Can you please look at this whole snippet of code and tell me what it should look like?

Code:
$ch = curl_init("[url]http://www.somepaymentprocessor.com"[/url]);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, "storename=12345&chargetotal=1.00&mode=payplus");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);

Also, as far as emails: yes the email does go out if I don't select to process the CURL script. Only doesn't go out I check the CURL checkbox and have the above CURL script in there.

Thanks much. I would like to resolve this issue soon as it has been lingering for a while now.
 
hi

Found the problem - to fix download the latest svn or in components/com_fabrik/fabrik.class.php around line 1087 eplace:

Code:
			if( $onlyProcessCurl == 2 ){
				$this->postCurl( );
				return true;
			}

with

Code:
			if( $onlyProcessCurl == 2 ){
				$this->postCurl( );
			}
 
This seems to have resolved the email sending issue. It also seems to have resolved the issue of the page loading within the existing page's frame.

However, I am now facing another related problem...I don't seem to get the posted parameters on my jump page. The payment processor was showing as no parameter passed in, so then I tried by building my own jump to page in Joomla and putting in some PHP code (using kl_php) and nothing comes up. Here is the code I am using to check the POST parameter(s):

Code:
echo mosGetParam($_PUT, 'chargetotal', '');

Am I doing something wrong in my CURL? Do I need to explicitly denote the fields I want posted using the CURLOPT_POSTFIELDS as I am doing? Should I be using header('Location: http://www.somepaymentprocessor.com/') instead of curl_init("http://www.somepaymentprocessor.com");

Please help. Thanks.

mamamia.
 
try:

Code:
echo mosGetParam($_REQUST, 'chargetotal', '');

$_REQUEST cotains both the post ($_POST) and query string ($_GET) data, I'm not sure if $_PUT is valid
 
That did not work. Any other ideas?

btw, I may have had a mistake in reading the parameters by using $_PUT, however, I don't believe that is the core of my problems. Keep in mind that the payment processor's page also tells me that I am not passing in any parameters. Thus, I imagine something is wrong with my CURL script or the Fabrik logic where the elements are not being posted properly.

mamamia
 
right

in that case the curl page takes the post values that are passed in with this line of your script:

Code:
curl_setopt($ch, CURLOPT_POSTFIELDS, "storename=12345&chargetotal=1.00&mode=payplus");

try something like this instead:

Code:
$str = "storename=12345&chargetotal=1.00&mode=payplus";
foreach($_REQUEST as $key => $val ){
 $str .= "&$key=$val";
}
curl_setopt($ch, CURLOPT_POSTFIELDS, $str);
 
Rob,
That did not do any good. I am not sure what exactly you were trying to achieve with that piece of code....my intention for now is to simply hardcode those three key/value pairs as POST variables. I can't even manage to do that.

Also, another interesting point that I just noticed: The Joomla jump page that I have built which Fabrik redirects to has a GET parameter in it. The URL looks something like this: http://www.mywebsite.com/content/view/44/69?&Itemid=67

Furthermore, when I press the Refresh button on the jump page, the browser does not pop up the usual warning message that the page was reached via a POST and am I sure I want to refresh.

I am starting to suspect that maybe a POST is not really taking place, but rather a GET. What do you think?

mamamia
 
hi

that code takes all post and get variables and sends them to the page you're curl code points to, which I think was your initial question?


A post is occuring on the form. The fabrik jump page takes the posted form data, converts it into a query string and redirects the browser to the next page.
 
I am very confused now.....

First and foremost, can you please explain how the Jump page fits into the flow when using CURL to POST? I would think that it should be ignored and have no effect since a new page is defined in the CURL POST parameters using curl_init.

Secondly, to clarify what I am trying to do...very simple....
After the user populates the form and presses the Submit button, I want all (or some) of the parameters to be sent to another page or website via POST method.

Those parameters must come in POST method because that is the way the payment processor requires them to be...not GET.

For beginners, I am not even attempting to go to the payment processor's website. I just want to go to my own Joomla static content page and make sure that I can retrieve all the form variables from the request that should have been posted.

Help. Thanks.

mamamia
p.s. I really hope that the revised version of the Fabrik doc has nice clear example of this operation so that others don't struggle like me.
 
The jump page url is built and run at the end of the form processing.
Due to my misunderstanding of your initial questions the code I changed in the form processing is now wrong, i.e it should be

Code:
			if( $onlyProcessCurl == 2 ){
				$this->postCurl( );
				return true;
			}

rather than

Code:
			if( $onlyProcessCurl == 2 ){
				$this->postCurl( );
			}

this ensured that the jump page will NOT be called if a CURL script was used.

The jump page by definition sends the data as part of the query string, so you CANT access it with the $_POST variable. think of the process as this (each web page called is encased in []):
Code:
     [fabrik form on web page] 
           |
     submit post data 
           | 
     [fabrik processor]
           |
     curl page selected? 
           |
  ----------------------------
  |                 |
  Yes               No
  |                 |
run code in CURL script    process & REDIRECT to jump page url 
  |                 |
[page specified in        |
CURLOPT_URL option]    [jump page]

The code I posted (curl_setopt($ch, CURLOPT_POSTFIELDS,.....) WILL send the data as POST to the CURL page you specify, please familarise yourself with the possible options for using CURL here :

http://fr2.php.net/manual/en/function.curl-setopt.php
 
Rob,
I reverted back the changes as you described. Although now I am able to retrieve the POST parameters, I am back to the original 2 issues that started this thread:

1. The POST page as denoted in the CURL script is shown within the frame of my existing site. This looks very ugly, especially if anyone plans on posting to an internal page as now there are 2 headers, 2 left nav bars, etc.

2. No email is sent to the admin.

Also, it may be worth noting that what I have in my components/com_fabrik/fabrik.class.php on line 1087 is slightly different than what you described:

Code:
if( $onlyProcessCurl == 2 ){
 if( $this->use_curl ){
  $this->postCurl( $aData );
  return;
 }
}

I am using Fabrik 1.0.4, not from the Forge, just the regular download version that is available to members.
 
for 1) Sorry I never use Iframes in a website for layout, so have no idea how to do what you need there. At a guess I would say you would need to write some javascript to check the url of that frame and then make that url the main page's url. That or use a template that doesn't use frames (much better for SEO etc)

for 2) this has been fixed in the SVN. A quick 'hack' to fix it would be to do this:

add

Code:
			if ( $this->email_to != "" && !$this->_admin ){
				$this->sendEmail( $fileUploadFound );
			}

before

Code:
			/**** run the curl/php code after receipt sent ****/
				
			if( $onlyProcessCurl == 2 ){
				$this->postCurl( );
				return true;
			}

then further down

replace

Code:
if ( $this->sendEmail( $fileUploadFound ) ) {

with

Code:
if ( isset( $this->form_submit_jumppage ) && $this->form_submit_jumppage != "" ) {
 
Rob Clayburn said:
for 1) Sorry I never use Iframes in a website for layout, so have no idea how to do what you need there.
FYI: I am not using IFrames or Frameset anywhere in my site.

I think I will just wait until the 1.0.4 release and hopefully a lot of bugs will be out of the software. Any set date on the 1.0.4 release?

mamamia
 
Hi

No date, I'm working on test scripts for the upcoming release, but as usual these things take time

Cheers
Rob
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top