curl

Problem with python curl while submitting file

#!/usr/bin/python import pycurl import re import StringIO #CONSTANTS URL = "http://www.imagehost.org" FILE = "/datos/poop1.jpg" POST_DATA = [("a", "upload"), ("file[]", (pycurl.FORM_FILE, FILE))] buffer = StringIO.StringIO() c = pycurl.Curl() c.setopt( c.URL, URL ) c.setopt( c.POST, 1 ) c.setopt( c.POSTFIELDS, POST_DATA ) ##c.seto...

How to use PHP to get a webpage into a variable

I want to download a page from the web, it's allowed to do when you are using a simple browser like Firefox, but when I use "file_get_contents" the server refuses and replies that it understands the command but don't allow such downloads. So what to do? I think I saw in some scripts (on Perl) a way to make your script like a real browse...

CURL for WAMP

I’m new to PHP and I’m trying to learn how to parse information, I’m trying to use CURL but I’m not able to install it on my desktop WAMP on Windows Vista. How do I install CURL? ...

SFTP from within PHP

Hi guys, I'm in the process of building an web app that will, besides other things, need to connect to a FTP server to download or upload files. The application is written in PHP and it's hosted on a Linux server. What I was wondering is whether or not it would be possible to also provide support for SFTP servers, but after some quick ...

HTTP Authentication in Python

Whats is the python urllib equivallent of curl -u username:password status="abcd" http://example.com/update.json I did this: handle = urllib2.Request(url) authheader = "Basic %s" % base64.encodestring('%s:%s' % (username, password)) handle.add_header("Authorization", authheader) Is there a better / simpler way? ...

Wordpress autologin using CURL or fsockopen in PHP

Client wants to click a link and auto login to Wordpress backend admin section. I tried using fsockopen, code below. Didn't work. $post_data['user_login'] = 'admin'; $post_data['user_pass'] = 'password'; $post_data['wp-submit'] = 'Log In'; $post_data['redirect_to'] = 'http://example.com/wp-admin/'; //traverse array and prepare data fo...

PHP curl post to login to Wordpress

i am working on a project for a client which needs an automatic login from a link click. I'm using a handshake page to do this with the following code: $username="admin"; $password="blog"; $url="http://wordpressblogURL/"; $cookie="cookie.txt"; $postdata = "log=". $username ."&pwd=". $password ."&wp-submit=Log%20In&redirect_to=". $url ...

Error using PHP cURL with SSL certificates

I'm trying to write a PHP script using cURL that can authorize a user through a page that uses an SSL certificate, in addition to username and password, and I can't seem to get past the SSL cert stage. In this case, curl_setopt($handle, CURLOPT_VERIFYPEER, 0) unfortunately isn't an option. The certificate is a required part of authenti...

What does this change I'm seeing in this cURL HTTP POST cookie response indicate?

Hi, I'm using cURL and php to query an exchange server that has Forms Based Authentication turned on. Due to FBA being on I need to collect a user's cookie authentication ids first. Yesterday everything was working: then something changed overnight and stopped working. I noticed that the cookie ids I was getting back were different (not ...

How to get CURL to save to a different directory?

I need to be able to pass in the URL of the file download, plus a path for the file to be saved to. I think it has something to do with -O and -o on CURL, but I can't seem to figure it out. For example, this is what I'm using in my bash script now: #!/bin/sh getsrc(){ curl -O $1 } getsrc http://www.apache.org/dist/ant/binaries/a...

What are the problems associated with retrieving email using CURL?

A new feature I wish to add to our local network is the ability to retrieve email from free email services such as Gmail, Yahoo and Hotmail using PHP. There are services we can pay for but I would rather hack it up myself! I find that Google only has an API but the rest do not. What are the problems associated then with me just retrievi...

can cURL be used to read php code from php files?

I am sorry if this is a dumb question but if I didn't ask I wouldn't know. I don't really understand how cURL works, can it read the unparsed php code from a php file? If so, what is to stop some hacker from reading the script that connects to my data-base and stealing the login info? Thanks. ...

file_get_contents (or curl, or fopen) problem with session data.

hello, i have a page that shows a value from session, lets call it www.domain-a.com/master.php and if i type it directly from the browser, it shows me the session value. but when i try to download it with file_get_contents (or other method) from another domain, like www.domain-b.com/slave.php, it is not retrieving the content protected...

PHP / Curl: HEAD Request takes a long time on some sites

I have simple code that does a head request for a URL and then prints the response headers. I've noticed that on some sites, this can take a long time to complete. For example, requesting http://www.arstechnica.com takes about two minutes. I've tried the same request using another web site that does the same basic task, and it comes bac...

Curl function to select options from a select box and auto submit

Hi all i am a newbie and try different things everyday and always come here when i am stuck with something. I want to write a script using curl and php that goes to this link :http://tools.cisco.com/WWChannels/LOCATR/openBasicSearch.do and then goes through each page for each country capturing a list of every partner in every country a...

PHP and HTTP Header Line Breaks: What character used to represent?

I'm looping through each line of a series of CURL returned http headers, trying to detect when one ends and the next begins. I know that an http header terminates with an empty line, but what character is used to represent this line break in php? I've tried with \n but it doesn't seem to work. I certainly could be doing something wrong. ...

Repetition of group patterns in a regex pattern

So, folks, I have this self crafted pattern that works. After some hours (I am no regex guru) this puppy evolved to parse curl PUT output for me: ^\s*([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+) \s+([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+)\s+([^ ]+) (CR in text only for formatting) It gives me 'groups' that...

Hiding responses using PHP and Curl

I am reusing a curl function from a long time ago that is now acting differently than I remember. In this particular case, I'm authenticating a user's Twitter credentials. Here's the code as it stands now: $cred = $_POST['twitter_username'].':'.$_POST['twitter_password']; $url = "http://twitter.com/account/verify_credentials.json"; $c...

Use Cacti to Monitor HTTP Status Codes of Request Responses?

I have a proxy script that makes HTTP GET requests to other pages using cURL through PHP. Is it possible to monitor what response codes are returned to those cURL requests, using Cacti? If not Cacti, possible with any similar monitoring system? For example, I want a report that shows how many responses came in each status category, ie,...

Login into Facebook with PHP script, but let me logged in the browser after the end of this script

Please, I am solving this problem.. I need to login into Facebook or Twitter or any other website from my PHP script running on my server. I am normaly doing that with CURL, saving cookies to some predefined file. But now I need something new.. I need to stay logged in with my browser, even when the script ends the login process. Is that...