Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
AJAX POSSIBLY CURL or SOAP, not sure!
Old 02-23-2009, 09:33 PM AJAX POSSIBLY CURL or SOAP, not sure!
Average Talker

Posts: 15
Trades: 0
I am simply not sure on this one. The great thing about the web is you are always coming across new things. I have been trying to troubleshoot this on my own all day but have not been able to come up with any solution.

The Problem: the problem at hand is I need to access a remote url http://socket.somewebsite.com:8080/?...XXX&INV_DATE=N
&ONE_OWNER=Y

This simple socket only displays a 'Yes' or 'No' for the REQUEST (optionaly if I request and set the INV_DATE to Y then I will get the expiration date in the following format 07/15/04 and if I set ONE_OWNER to Y then I will get either a 1 or No as the response).

As it is now I do not need the INV_DATE but I do need to figure out how to get the response from the page which will be in most instances "Yes 1" or "Yes No" base on my example URL above.

The problem I am having is I do not know how to retrieve the response from the remote server. I have set up plenty of examples on my own local server and tested using AJAX and my AJAX script work with the dynamic script I set up locally but I cannot retrieve the response from the remote server using this same method. I looked into CURL option but only the first record on my local dynamic page will display and all the following records are giving me a security error message response from the remote server.

I was thinking SOAP may be an option but I am not familiar enough with SOAP nor do I even know if it is enabled on my server. I do have admin rights to my server if you need to know this. No, I will not give out my username and pswd to it. Just thought that if you asked I could tell you I do have this kind of a access to my server. I do not know where I would enable SOAP using WHM cPanel though.

Any help or point in the right direction on this would be great. I have to pull this socket page every time a record displays. So on my local page there will be multiple records and each time a record is displayed from the database I need to make a call to this remote URL, somehow capture the response it gives, and then I need to display an icon based on the response I get. I would like to make sure i accomplish this without to much server overload and make sure it executes quickly as response time on the page is important.
macbaby is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-23-2009, 09:58 PM Re: AJAX POSSIBLY CURL or SOAP, not sure!
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
SOAP will only work with a SOAP response. It's an XML based transfer and response that uses named spaces using a WDSL file for the declarations. Unless the response is a SOAP response, it's not going to work good for you.

SOAP also is not enabled in PHP by default so you would need SSH to compile it on a nix system.

AJAX alone will also not work since browser security only allows AJAX requested through the same domain as the page. AJAX is also entirely client side so if there could be sensitive data passed by altering the requesting url, then this is a bad idea.

However, CURL is the best bet, and you could even combine AJAX with CURL with your server responding with controlled data.

How many records are you displaying in a page view? If there are a large number, you could implement pagination to limit the rows for each page view. If you still require many rows, you can use the AJAX/CURL method to allow the client side to request the response for each row, one at a time. This way a full page to generate by the server will be broken down to multiple requests and the visitor can still see the page completed while AJAX is updating each row.

If the information is static for each request, you could also build a caching system using a db to store results for rows already diplayed prior.
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 02-24-2009, 11:53 AM Re: AJAX POSSIBLY CURL or SOAP, not sure!
Average Talker

Posts: 15
Trades: 0
Yes, I am using pagination so only 10 record per page at most. This helps with the load time. I did try to set it up so that every time a record displays it would use the code (CURL) to execute. I found that a. its not working properly. Only for the first record does it execute properly. Then the remaining records give me error responses from the remote server. Also I noticed the page loads very slowly. Mixing AJAX with the curl may be an option. I will have to explorer this. I am not familiar enough with CURL. Any ideas.
macbaby is offline
Reply With Quote
View Public Profile
 
Old 02-24-2009, 02:45 PM Re: AJAX POSSIBLY CURL or SOAP, not sure!
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
Are the following CURL urls malformed or distorted to cause the problems? If not, the remote server may have restrictions set in place to avoid "brute-force" or a firewall to slow requests???
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 02-25-2009, 06:12 PM Re: AJAX POSSIBLY CURL or SOAP, not sure!
Average Talker

Posts: 15
Trades: 0
Alright since the company I am trying to work with does not want to provide any support on how to implement their own product I have been forced to disclose the code I am trying to execute in order to find a solution for this. My client is get antsy and if the company that is providing the product does not want to cooperate then I will find another solution. Here is what I have:
<?php
error_reporting(0);
$myVin = $_GET['vin'];

$post_data = array();
$post_data['REQUEST'] = 'INV';
$post_data['VIN'] = $myVin;
$post_data['UID'] = 'C412012';
$post_data['INV_DATE'] = 'N';
$post_data['ONE_OWNER'] = 'Y';

//build the post string
/*foreach($post_data AS $key => $val){
$poststring .= urlencode($key) . "=" . urlencode($val) . "&";
}*/
// strip off trailing ampersand
//$poststring = substr($poststring, 0, -1);

// create a new CURL resource
$ch = curl_init();

// set URL and other appropriate options
//curl_setopt($ch, CURLOPT_POST, 1);
//curl_setopt($ch, CURLOPT_HEADER, 0);
//curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_URL, "http://socket.CARFAX.com:8080/?UID=MYUSERID&REQUEST=INV&VIN=$myVin&INV_DATE=N&ON E_OWNER=Y");
//http://socket.carfax.com:8080/?UID=MYUSERID&REQUEST=INV&VIN=AVEHICLESVIN&INV_DAT E=Y&ONE_OWNER=Y

//curl_setopt($ch, CURLOPT_POSTFIELDS, $poststring);

// grab URL and pass it to the browser
curl_exec($ch);
// close CURL resource, and free up system resources
curl_close($ch);

?>

Essentially what I am trying to do is capture the response. Right now if I can only do it on the vehicle detail pages then that is fine. That gives me something to work with. Currently this code executes and works albeit slowly. Can you help me figure out how I am suppose to capture the response from the other companies server? I can see the response on my page which will be either 'Yes 1', 'Yes N' or 'No'
This is just a simple response from their server so I am not sure how to load this into a variable that I can then utilize with .php on my end to do what it is I need to do. Any help would be appreciated.
Thanks.
macbaby is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to AJAX POSSIBLY CURL or SOAP, not sure!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.36104 seconds with 12 queries