Jump to content

Search the Community

Showing results for tags 'cURL'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome
    • Announcements & News
    • New Arrivals
  • Web Development
    • Programming
    • Database Development
    • Server Administration
    • Hosting & Domains
    • Frameworks
  • Web Design
    • HTML & CSS
    • Graphics & Multimedia
  • Desktop Discussion
    • Linux Development
    • Windows Development
    • Mac/Apple Development
    • Hardware Discussion
  • Marketing & Business
    • Advertising, Marketing, Monetization & Social Media
    • Search Engine Optimization & Traffic Building
    • Buy, Sell or Trade
  • Prodjex Web Development Applications, Tools and Plugins
    • IP.Board Applications and Plugins
    • Web Tools
  • The Developer Dump
    • General Chat

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

Found 4 results

  1. MailChimp allows you to create sign up forms with their builder, but they can be a pain to style and for some don’t allow enough customization. The following code is an example of how you can take advantage of the MailChimp API to subscribe new users. Doing this allows you to then create a custom sign up form and style it easily to match your own look and feel. This example assumes you’re only passing the First Name, Last Name, and email of a new subscriber. It’s easy enough to add additional fields, but this will get you started. First you’ll need to setup an API key in your MailChimp account, so login and navigate to Account -> Extras -> API Keys. Once you’ve clicked to create a new API key go ahead and copy the API key and place it in your code. Now you will need to find the list ID. This is not the ID of the list from the URL. You need to go to your lists and in the drop down select settings. Scroll all the way down and here you will find your list ID to replace in the code. You’re all set, now create your form matching the names from the following script and set your form action to “GET”. <?php /** * Created by PhpStorm. * User: Prodjex * Date: 1/31/2018 * Time: 9:04 AM */ //Grab Data Variables Passed From Form $data = [ 'email' => $_GET['email'], 'status' => 'subscribed', 'firstname' => $_GET['firstname'], 'lastname' => $_GET['lastname'] ]; syncMailchimp($data); function syncMailchimp($data) { $apiKey = 'Your API KEY'; $listID = 'Your List ID'; $memberID = md5(strtolower($data['email'])); $dataCenter = substr($apiKey, strpos($apiKey, '-') + 1); $url = 'https://' . $dataCenter . '.api.mailchimp.com/3.0/lists/' . $listID . '/members/' . $memberID; $json = json_encode([ 'email_address' => $data['email'], 'status' => $data['status'], // "subscribed","unsubscribed","cleaned","pending" 'merge_fields' => [ 'FNAME' => $data['firstname'], 'LNAME' => $data['lastname'] ] ]); $ch = curl_init($url); curl_setopt($ch, CURLOPT_USERPWD, 'user:' . $apiKey); curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, $json); $result = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); return $httpCode; } View Blog Post
  2. What's the best method to pull data from this page? I want to grab different details and insert into my database using PHP. I assume I have to do something with CURL? http://www.zillow.com/webservice/GetDeepSearchResults.htm?&zws-id=REDACTED&address=1016+Redwood+Lane&citystatezip=Liberty%2C+Missouri+64068
  3. So this is my first little mini tutorial here. Hope someone will like it/find it useful. Basically what we are going to do is scrape some data from a remote website using PHP and cURL. cURL is a "client URL transfer library" for making all sorts of remote requests and is very useful for many things like getting data, logging in automatically, auto filling out forms etc. Lets get cracking! First and foremost we have to enable the cURL extension as this is not enabled by default. On a Windows machine edit your php.ini file and uncomment ;extension=php_curl.dll and restart your server. If you are using Ubuntu sudo apt-get install php5-curl and restart server. I use a WAMP server at home and it is super easy to install extensions on it simply: Go to icon down in the right corner of your screen->left click WAMPSERVER icon->PHP->PHP extensions->click on php_curl and then restart server. Voila! Alright now we are going to initiate cURL and make a request to another site and display the html with an echo: <?php $url = "http://www.nytimes.com/"; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($ch); curl_close($ch); echo $result; ?> Now that we have the html inside $result we can extract the data we are after using regular expressions. In this case I took a regex from http://regexlib.com/ to extract links and modded it just a little bit to make it work. You can just comment out the previous echo $result; and paste these 2 lines in there. preg_match_all("/<a[\s]+[^>]*?href[\s]?=[\s\"\']*(.*?)[\"\'].*?>([^<]+|.*?)?<\/a>/is", $result, $match, PREG_SET_ORDER); print_r($match); This is how this stuff works. Pretty easy basic stuff. You can read more about PHPs cURL support here http://php.net/manual/en/book.curl.php. I especially recommend the curl_setopt part were you can make all kinds of cool stuff like setting an user agent, set referrer, set cookie and a bunch of other stuff to mimic your request coming from an actual user. Any questions or suggestions, just fire away in the thread! More information on cURL: http://curl.haxx.se/
  4. So this one has been getting to me for a while now.. There is a site that I am trying to log in to, go to a reports page after a successful login, and then download up to 3 reports that are linked on that page. The problem that I'm having is that the reports are randomly named, and I can't get curl to download them. I'll post the html file that the site spit back out to me.. Can someone see how to download the 3 files that are on that page without hardcoding the file name? The 3 reports are named: My Company Invoice Upload_516_146_2012391728360 My Company Invoice Upload_516_146_20123917221402 My Company Patient Upload_516_146_2012391723258 My Scheduled Reports.htm
×
×
  • Create New...