当前位置: 首页>>代码示例>>PHP>>正文


PHP Curl::exec方法代码示例

本文整理汇总了PHP中Curl::exec方法的典型用法代码示例。如果您正苦于以下问题:PHP Curl::exec方法的具体用法?PHP Curl::exec怎么用?PHP Curl::exec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Curl的用法示例。


在下文中一共展示了Curl::exec方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getIp

 public static function getIp()
 {
     $co = new Curl(self::$ifconfigIp);
     $co->setopt(CURLOPT_RETURNTRANSFER, true);
     $ip = $co->exec();
     return $ip;
 }
开发者ID:braph,项目名称:dottk,代码行数:7,代码来源:ifconfig.php

示例2: Curl

 function test_mock()
 {
     Curl::initMock();
     Curl::mockResult("helloworld");
     $curl = new Curl();
     $res = $curl->exec();
     $this->assertEquals($res, "helloworld");
 }
开发者ID:tunapanda,项目名称:wp-remote-sync,代码行数:8,代码来源:test-Curl.php

示例3: Curl

 function __construct($username, $password)
 {
     $curl = new Curl($this->loginUrl);
     $curl->setRefer($this->refer);
     $formData = array("shop_user" => array("login" => $username, "pass" => $password, "mem" => "on"), "auth" => "войти на сайт");
     $curl->setReturnTransfer(true);
     $curl->sendPostForm($formData);
     $curl->exec();
     echo curl_getinfo($curl, CURLINFO_HEADER_OUT);
     $curl->close();
 }
开发者ID:Zir4onah,项目名称:test,代码行数:11,代码来源:kinopoisk.php

示例4: testCurlWrapperCanDoHttpQueries

 function testCurlWrapperCanDoHttpQueries()
 {
     $curl = new Curl(self::TEST_VALID_URL);
     $curl->setopt(CURLOPT_PROXY, $this->proxy);
     $this->assertTrue($curl->setopt(CURLOPT_RETURNTRANSFER, 1));
     $this->assertTrue($curl->setopt_array(array(CURLOPT_TIMEOUT => self::CURL_TIMEOUT, CURLOPT_FOLLOWLOCATION => true)));
     $result = $curl->exec();
     $this->assertStringStartsWith('<!doctype html>', $result);
     $curl->close();
     $this->assertFalse($curl->hasHandle());
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:11,代码来源:CurlTest.php

示例5: url_exists

 /**
  * url_exists function.
  * Checks to see if an url exists
  * 
  * @access public
  * @param string $url
  * @return bool
  */
 public static function url_exists($url)
 {
     $curl_options = array(CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_URL => $url);
     $curl = new Curl($curl_options);
     try {
         $curl->exec();
         $error = FALSE;
     } catch (Exception $e) {
         $error = TRUE;
     }
     return $error;
 }
开发者ID:sydlawrence,项目名称:SocialFeed,代码行数:20,代码来源:socialFeed.php

示例6: getComments

 /**
  *
  * Return case's comments; I assume that there wouldn't be single requests for events of more than 1 case
  * (comments should be show when user clicks on proper button
  * Important: Function is not ready and not used yet.
  * that might be corrected/developed in future
  * 
  * THIS NO WORK !!!
  * THIS NO WORK !!!
  * 
  * @param int $caseID
  */
 public function getComments($caseID)
 {
     $res = 'No comments for this case.';
     $this->resetParams();
     $this->setParam('cmd', 'search');
     $this->setParam('token', $this->token);
     $this->setParam('q', $caseID);
     $this->setParam('cols', 'events');
     $this->curl->setopt_array($this->getCurlOptions());
     $xml = $this->curl->exec();
     if (!empty($xml)) {
         $dom = new DOMDocument();
         $dom->loadXML($xml);
         //$case = $dom->getElementsByTagName( 'case' );
         $events = $dom->getElementsByTagName('event');
         //->item(0)->nodeValue;
         unset($res);
         $res = array();
         foreach ($events as $event) {
             $res[] = array('ixPerson' => $event->getElementsByTagName('ixPerson')->item(0)->nodeValue, 'sPerson' => $event->getElementsByTagName('sPerson')->item(0)->nodeValue, 'ixPersonAssignedTo' => $event->getElementsByTagName('ixPersonAssignedTo')->item(0)->nodeValue, 'dt' => $event->getElementsByTagName('dt')->item(0)->nodeValue, 'evtDescription' => $event->getElementsByTagName('evtDescription')->item(0)->nodeValue, 'sChanges' => $event->getElementsByTagName('sChanges')->item(0)->nodeValue);
         }
     }
     return $res;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:36,代码来源:FogbugzService.class.php

示例7: Curl

<?php

include '../lib/Curl.php';
include '../lib/Curl/Share.php';
/**
 * curl_share_init() example
 *
 * http://php.net/manual/en/function.curl-share-init.php#refsect1-function.curl-share-init-examples
 */
// Create cURL share handle and set it to share cookie data
$sh = new Curl\Share();
$sh->setopt(CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
// Initialize the first cURL handle and assign the share handle to it
$ch1 = new Curl("http://example.com/");
$ch1->setopt(CURLOPT_SHARE, $sh);
// Execute the first cURL handle
$ch1->exec();
// Initialize the second cURL handle and assign the share handle to it
$ch2 = new Curl("http://php.net/");
$ch2->setopt(CURLOPT_SHARE, $sh);
// Execute the second cURL handle
//  all cookies from $ch1 handle are shared with $ch2 handle
$ch2->exec();
// Close the cURL share handle
$sh->close();
// Close the cURL handles
$ch1->close();
$ch2->close();
开发者ID:seebz,项目名称:oo-curl,代码行数:28,代码来源:curl_share_init.php

示例8: Curl

<?php

require_once __DIR__ . "/../../src/utils/Curl.php";
$curl = new Curl("http://learning.tunapanda.org/wp-content/plugins/wp-remote-sync/tests/lab/recvfile.php");
$curl->setopt(CURLOPT_RETURNTRANSFER, TRUE);
$curl->setopt(CURLOPT_POST, 1);
$curl->addFileUpload("thefile.txt", __DIR__ . "/file.txt");
$res = $curl->exec();
echo $res;
开发者ID:tunapanda,项目名称:wp-remote-sync,代码行数:9,代码来源:uploadfile.php

示例9: Exception

 // If something happened, (which it shouldn't) throw an exception
 if (!$curl) {
     throw new Exception("I couldn't create a Curl object. Was PHP compiled with cURL?");
 }
 /**
  * Set the URL for $curl to our test location:
  */
 $curl->url = "http://jamessocol.com/projects/oocurl_test.php";
 /**
  * Set a custom header for the test.
  */
 $curl->httpheader = array('X-OOCurl-Version: ' . Curl::VERSION);
 /**
  * Execute the HTTP query
  */
 $response = $curl->exec();
 // If there's no response, there was an error.
 if (!$response) {
     throw new Exception("I couldn't fetch the response.");
 }
 printf("Single request: Success: %s\n", $response);
 printf("I downloaded %n bytes!\n", $curl->info('size_download'));
 // Now we'll test the parallel processor
 /**
  * Let's fetch Yahoo
  */
 $y = new Curl("http://www.yahoo.com/");
 /**
  * And let's grab Google, too
  */
 $g = new Curl("http://www.google.com/");
开发者ID:jsocol,项目名称:oocurl,代码行数:31,代码来源:test.php

示例10: onPercent

<?php

require_once __DIR__ . "/../../src/utils/Curl.php";
/*$curl=new Curl();
	$curl
		->setopt(CURLOPT_URL,"http://localhost/repo/wp-remote-sync/tests/lab/recvfile.php?getarg=1&json=1")
		->setopt(CURLOPT_RETURNTRANSFER,TRUE)
		->setResultDecoding(Curl::JSON);
	$res=$curl->exec();

	print_r($res);*/
/*	$curl=new Curl("http://localhost/wp-sync-test-remote/wp-content/plugins/wp-remote-sync/api.php");
	$curl
//		->setopt(CURLOPT_RETURNTRANSFER,TRUE)
		->addPostField("action","getAttachment")
		->addPostField("type","attachment")
		->setResultDecoding(Curl::JSON)
		->addPostField("slug","3d")
		->addPostField("key","")
		->addPostField("attachment","2016/01/3D2.png")
		->setDownloadFileName("hello.png");
	$res=$curl->exec();*/
function onPercent($percent)
{
    echo "percent: " . $percent . "\n";
}
$curl = new Curl("http://localhost/repo/wp-remote-sync/tests/lab/generatelongcontent.php");
$curl->setPercentFunc("onPercent");
$curl->setopt(CURLOPT_RETURNTRANSFER, TRUE);
$curl->exec();
开发者ID:tunapanda,项目名称:wp-remote-sync,代码行数:30,代码来源:curltest.php

示例11: Curl

<?php

session_start();
//print_r( $_SERVER );
//exit;
include "classes/curl.class.php";
$url_root = "http://kebot.me/dic/";
$oauth_url = $url_root . "OAuth.php";
$api_url = $url_root . "api.php";
if (isset($_SESSION[uid])) {
    echo $_SESSION[uid];
}
//function begin(){
$curl = new Curl($oauth_url . "?app=begin");
$return = $curl->exec();
$para = json_decode($return, TRUE);
//print_r( $para );
$_SESSION["oauth_token_secret"] = $para["oauth_token_secret"];
$_SESSION["oauth_token"] = $para["oauth_token"];
echo $para[url] . "http://" . $_SERVER[HTTP_HOST] . $_SERVER[PHP_SELF];
//}
//begin();
switch ($_GET[app]) {
    case "login":
        break;
}
开发者ID:jinguanio,项目名称:onlinedict,代码行数:26,代码来源:index.php

示例12: Curl

<?php

include '../lib/Curl.php';
/**
 * curl_init() example
 *
 * http://php.net/manual/en/function.curl-init.php#refsect1-function.curl-init-examples
 */
// create a new cURL resource
$ch = new Curl();
// set URL and other appropriate options
$ch->setopt(CURLOPT_URL, "http://www.example.com/");
$ch->setopt(CURLOPT_HEADER, 0);
// grab URL and pass it to the browser
$ch->exec();
// close cURL resource, and free up system resources
$ch->close();
开发者ID:seebz,项目名称:oo-curl,代码行数:17,代码来源:curl_init.php


注:本文中的Curl::exec方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。