
I am trying to design some code that will grab a CSV report remotely via PHP. I can successfully login to Salesforce using PHP Toolkit but after this I get a bit lost.
When I try to grab the CSV via a URL https://eu1.salesforce.com/REPORTID?csv=1&enc=UTF-8 I get a login error. Salesforce no longer thinks I am logged in due to changing page, most likely because I am not sending the sessio ID.
I came across this post http://boards.developerforce.com/t5/General-Development/How-can-I-export-a-report-as-a-CSV-ideally-scheduled-to-email-or/td-p/313079T
The second post says this:
"2) Export from salesforce.com remotely. Set up a cron job on the server to extract the data. Have the script/program log in programmatically to salesforce.com (API should be okay, or just use the normal login.salesforce.com portal). Then, call your report using the following HTTP request:
GET /<report-id>?excel=1 HTTP/1.1
Host: <instance>.salesforce.com
Cookie: sid=<session-id>
<other HTTP headers here>"
So I logged in programmitcally via Toolkit and I am lost with the following bit. How do I perform this HTTP request? I would guess via cURL but I am not 100% sure how to set it up. I've used cURL before but this looks more complex than what I'm used to. I tried putting the session ID in a cookie file and setting the cookie with these lines:
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookies.txt");
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookies.txt");
But this didn't help.
Now I am stuck. Does anyone have an idea?
2 respuestas