Developer Forum [ All Topics | New Topic ]

Thread: Feed works. Now what?

Hello,

I managed to get the feed script to work.  However, I was looking in to building my own search function on my website.  What would I have to do in order to achieve this? 

Would I have to create a script to automatically update the database from the csv file?

Has any one done this before?  

Thanks,

Sagar


>> add a comment
Sagar
05/27/2011 03:12


5 Replies:

You have a couple of options, I think you better read this first, to decide what you need:http://technet.rapaport.com/Info/RapLink/Default.aspx




>> add a comment
Leo Muller
5/29/2011 12:57:00 AM
Okay, before I move on. 

When I import the csv file on the sever using curl, I am getting a "Bad Request" on the csv file.  Any idea what's triggering this? 

>> add a comment
Sagar
6/1/2011 3:42:00 AM
Can you post a code snippet?

Regards,

Leo


>> add a comment
Leo Muller
6/1/2011 4:01:00 AM
<?php
//1 - Authenticate with TechNet. The authentication ticket will be stored in $auth_ticket. Note this MUST be HTTPS.
$auth_url = "https://technet.rapaport.com/HTTP/Authenticate.aspx";
$post_string = "username=MYUSERNAME&password=" . urlencode("MYPASSWORD");
//create HTTP POST request with curl:
$request = curl_init($auth_url); // initiate curl object
curl_setopt($request, CURLOPT_HEADER, 0); // set to 0 to eliminate header info from response
curl_setopt($request, CURLOPT_RETURNTRANSFER, 1); // Returns response data instead of TRUE(1)
curl_setopt($request, CURLOPT_POSTFIELDS, $post_string); // use HTTP POST to send form data
curl_setopt($request, CURLOPT_SSL_VERIFYPEER, FALSE); // uncomment this line if you get no gateway response.
$auth_ticket = curl_exec($request); // execute curl post and store results in $auth_ticket
curl_close ($request);
//2 - prepare HTTP request for data. Copy the URL from the RapLink Feed page in RapNet.com: 
// go to: http://www.rapnet.com/RapNet/DownloadListings/Download.aspx, choose your parameters, and click
// generate code. Make sure to specify the columns wanted. This can produce a very long URL.
$feed_url = "GENERATED URL";
$feed_url .= "&ticket=".$auth_ticket; //add authentication ticket:
//prepare to save response as file.
$fp = fopen('import/rapnetfeed.csv', 'wb');
if ($fp == FALSE)
{
echo "File not opened";
exit;
}
//create HTTP GET request with curl 
$request = curl_init($feed_url); // initiate curl object
curl_setopt($request, CURLOPT_FILE, $fp); //Ask cURL to write the contents to a file
curl_setopt($request, CURLOPT_HEADER, 0); // set to 0 to eliminate header info from response
curl_setopt($request, CURLOPT_TIMEOUT, 300); //set timeout to 5 mins
curl_exec($request); // execute curl post
// additional options may be required depending upon your server configuration
// you can find documentation on curl options at http://www.php.net/curl_setopt
curl_close ($request); // close curl object 
fclose($fp); //close file;
//Special thanks to David Meyers for helping me to create the sample file. \\ :-) // 
?>


>> add a comment
Sagar
6/1/2011 8:11:00 PM
The code looks good to me... You get a $auth_ticket, right?
And it stops working on the second curl_exec?
Did you try a shorter query string, with only a few very specific parameters?

Can you email me your account number, I don't see any errors, but I want to see if any requests come through. My email is leo@diamonds.net.

Regards,

Leo


>> add a comment
Leo Muller
6/2/2011 1:02:00 AM