File: examples.php

Recommend this page to a friend!
  Classes of István Dombi  >  Webdice Utilities  >  examples.php  >  Download  
File: examples.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Webdice Utilities
Send requests with Curl and parse and write XML
Author: By
Last change:
Date: 4 years ago
Size: 1,117 bytes
 

Contents

Class file image Download
<?php
/**
 * Creaated by Dombi István <dombi.istvan@webdice.hu> <dombiistvan28@gmail.com>
 */
require_once dirname(__FILE__) . '/vendor/autoload.php';

/**
 * Example GET request
 */
$request = new Webdice\Utilities\Curl\Request('http://example.com', array('returntransfer' => 1));
$request->get(array('something' => 'value', 'other' => 'value2'));
//$request->debug();

/**
 * Example POST request
 */
$request = new Webdice\Utilities\Curl\Request(
   
'http://posttestserver.com/post.php?dir=webdice',
    array(
'returntransfer' => 1)
);
$request->post(array('something' => 'value', 'other' => 'value2'));
//$request->debug();

/**
 * Exmaple POST request WITH FILE TRANSFER
 */
$file = realpath('test.jpg');
$request = new Webdice\Utilities\Curl\Request(
   
'http://things.local/file_receive.php',
    array(
       
'safe_upload' => false
   
)
);
$request->post(array(
   
'file' => '@' . $file,
   
'post' => 'value'
));

/**
 * Example CUSTOM REQUEST
 */
$request = new Webdice\Utilities\Curl\Request('http://example.com', array(
   
'returntransfer' => 1,
   
'customrequest' => 'PUT'
));
$request->send();


For more information send a message to info at phpclasses dot org.