SharkBait Posted August 20, 2008 Share Posted August 20, 2008 Ok I have an weird issue and I am trying to figure out why it is working on my development server at home and not my live server. DevServer: PHP Version 5.2.3 cURL Version: 7.16.4 curl_getinfo($ch): [url] => http://twitter.com/direct_messages/new.xml [content_type] => application/xml; charset=utf-8 [http_code] => 200 [header_size] => 717 [request_size] => 260 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.199514 [namelookup_time] => 0.050506 [connect_time] => 0.086238 [pretransfer_time] => 0.086274 [size_upload] => 0 [size_download] => 1286 [speed_download] => 6445 [speed_upload] => 0 [download_content_length] => 1286 [upload_content_length] => 0 [starttransfer_time] => 0.19862 [redirect_time] => 0 Live Server: PHP Version 5.2.6 cURL VersioN: 7.18.2 curl_getinfo($ch): [url] => http://twitter.com/direct_messages/new.xml [content_type] => application/xml; charset=utf-8 [http_code] => 200 [header_size] => 717 [request_size] => 260 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.199514 [namelookup_time] => 0.050506 [connect_time] => 0.086238 [pretransfer_time] => 0.086274 [size_upload] => 0 [size_download] => 1286 [speed_download] => 6445 [speed_upload] => 0 [download_content_length] => 1286 [upload_content_length] => 0 [starttransfer_time] => 0.19862 [redirect_time] => 0 This is the script: <?php $text = 'This is a lot of fun right?'; $ch = curl_init('http://twitter.com/direct_messages/new.xml'); $userpwd = "{$username}:{$password}"; $data = 'user=' . $target . '&text=' . urlencode($text); curl_setopt($ch, CURLOPT_USERPWD, $userpwd); curl_setopt ($ch, CURLOPT_POST, true); curl_setopt ($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_NOBODY, 0); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_USERAGENT, $twit_plugin_name .' '. $twit_plugin_ver); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $response = curl_exec($ch); ?> According to the live server it is not getting any POST information and I am not sure why. Is there an option in php.ini or something that might be forcing PHP cURL to use GET and not POST? Now I have set data as a STRING and as an ARRAY and both return the same error message on my Live Server. What am I missing? What other things can I look for? Quote Link to comment Share on other sites More sharing options...
Third_Degree Posted August 20, 2008 Share Posted August 20, 2008 Things that could be your problem (but most likely not): 1)Seems strange to be HTTP posting to an .xml file. Sure this is correct? 2)You don't have definitions for a few of the variables, but I assume they are defined earlier in your script? 3)Are all the parameters necessary? Try it with just the userpwd, post, and postfields... My solution: Try forming an HTTP request with fsockopen and sending headers with fwrite/fputs instead of cURL. Quote Link to comment Share on other sites More sharing options...
SharkBait Posted August 20, 2008 Author Share Posted August 20, 2008 i was following Twitter's API with HTTP to an XML file. But with more investigation it might be an issue with a newer version of the libcURL which I think has issues with sending data after being redirected in the case of say load balancing. I tried the script on 3 servers in total. The live server has a newer version of the libcURL whereas the 2 other servers are back a few revisions. But I will try using an fsockopen and seeing what i get. Thanks for the suggestion! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.