guzzle

How to resolve syntax error, unexpected [ in guzzle?

匆匆过客 提交于 2019-12-01 09:45:18
问题 I am trying to using guzzle to pass the referer as mentioned by one of the stackoverflow user on one of my question asked here: related stackoverflow question unresolved require_once("../plugins/Guzzle/vendor/autoload.php"); //use GuzzleHttp\Client; $headers = ['Referer' => 'https://mywebsite.com']; $httpClient = new Client([ 'headers' => $headers ]); but above through the error: syntax error, unexpected '[' and nothing works.:( So can anyone please help me to find my mistake or what I am

php程序员如何开发区块链、以太坊、智能合约的教程

喜欢而已 提交于 2019-11-30 23:50:09
以太坊是备受关注的区块链,它基于密码学技术和P2P通信技术 构建了一个去中心化的平台,所有的交易同步保存在每个节点中, 通过将区块单向级联成链,以太坊有效的保证了交易的不可篡改: 智能合约平台 以太坊是第一个实现了虚拟机的区块链,因此为智能合约 - Smart Contract - 的运行提供了良好的支持环境。也正因为这个原因,以太坊被称为区块链 2.0,以区别于比特币代表的以数字加密货币为核心特征的区块链1.0。 可以将智能合约理解为机器之间的合同约定,在满足一定条件时自动 执行约定好的逻辑,例如在保险理赔流程中,如果理赔条件满足就自动 将赔偿金释放给出险人,这个流程就可以使用智能合约来实现。 有多种语言可以开发以太坊智能合约,但目前最常用的是类似于JavaScript的 Solidity语言。本课程中将采用Solidity讲解智能合约的开发。 JSON-RPC 如果我们希望构造一个去中心化应用(DApp),除了智能合约的开发, 通常还需要使用其他开发语言为用户提供操作智能合约的用户接口,例如 开发一个网页、一个手机App或者一个桌面应用。这些代码都需要与以太坊 进行交互。 以太坊规定了每个节点需要实现的JSON RPC API 应用开发接口,该接口是传输无关的,应用程序可以通过HTTP、websocket或IPC等多种 通信机制来使用该接口协议操作以太坊节点:

How to use oAuth with Guzzle 5 (or, better, with Guzzle 6)

独自空忆成欢 提交于 2019-11-30 23:23:16
I'm trying to connect to the WooCommerce API using Guzzle 5 (Guzzle 6 seems not has oAuth options o.O). Woocommerce requires the oAuth authentication method to work. This is the code I'm using: <?php /** * Example of usage of Guzzle 5 to get information * from a WooCommerce Store. */ require('../vendor/autoload.php'); use GuzzleHttp\Client; use GuzzleHttp\Subscriber\Oauth\Oauth1; use GuzzleHttp\Exception\RequestException; $consumer_key = 'my_consumer_key'; // Add your own Consumer Key here $consumer_secret = 'my_consumer_secret'; // Add your own Consumer Secret here $store_url = 'http:/

Guzzle and HTTPS

…衆ロ難τιáo~ 提交于 2019-11-30 21:25:36
I want to use Guzzle and Silex to send request to https pages. With http url I have a response : app->get('/',function() use ($app, $client){ $response = $client->get("http://www.google.fr"); var_dump($response); }); My response: object(GuzzleHttp\Message\Response)[102] private 'reasonPhrase' => string 'OK' (length=2) private 'statusCode' => int 200 private 'effectiveUrl' => string 'http://www.google.fr' (length=20) private 'headers' (GuzzleHttp\Message\AbstractMessage) => array (size=13) 'date' => array (size=1) 0 => string 'Wed, 18 Feb 2015 10:57:37 GMT' (length=29) 'expires' => But with

Unit Testing Guzzle inside of Laravel Controller with PHPUnit

房东的猫 提交于 2019-11-30 21:24:36
I'm not quite sure which way to approach unit testing in this scenario. None of the examples for unit testing Guzzle quite make sense to me how to implement in this scenario, or perhaps I'm just looking at it incorrectly all together. The setup: Laravel 4.2 REST API - A controller method is using Guzzle in the method to request data from another api as follows: <?php class Widgets extends Controller { public function index(){ // Stuff $client = new GuzzleHttp\Client(); $url = "api.example.com"; $response = $client->request('POST', $url, ['body' => array(...)]); // More stuff } } ?> I thought

How to crawl with php Goutte and Guzzle if data is loaded by Javascript?

余生颓废 提交于 2019-11-30 20:35:00
Many times when crawling we run into problems where content that is rendered on the page is generated with Javascript and therefore scrapy is unable to crawl for it (eg. ajax requests, jQuery) You want to have a look at phantomjs. There is this php implementation: http://jonnnnyw.github.io/php-phantomjs/ if you need to have it working with php of course. You could read the page and then feed the contents to Guzzle, in order to use the nice functions that Guzzle gives you (like search for contents, etc...). That would depend on your needs, maybe you can simply use the dom, like this: How to get

How do we specify TLS/SSL options in Guzzle?

被刻印的时光 ゝ 提交于 2019-11-30 17:54:06
We are starting to use Guzzle in PHP with code which calls a variety of different APIs, a few of which don't support TLSv1.2 and some of which require TLSv1.2. What's the best way to force Guzzle to use the most recent protocol available, except in cases where we know it won't be recognized? It is simple and easy. $client = new Client(); $guzzle = new GuzzleClient('https://www.yourweb.com', array( 'curl.options' => array( CURLOPT_SSLVERSION => CURL_SSLVERSION_TLSv1_2 ) )); $client->setClient($guzzle); ... In Guzzle 3.0+ (update as per @limos' comment): 'curl' => array( CURLOPT_SSLVERSION =>

Looping PHP Nested Arrays - Extract values into Blade Views (Laravel)

孤街醉人 提交于 2019-11-30 14:45:21
I know there are many questions on this topic, but none quite deal with this (as far as I could see). I have a PHP array (which FYI, is returned via Guzzle response) in a Laravel Project. The PHP array $users = array(2) { ["error"]=> bool(false) ["spirits"]=> array(2) { [0]=> array(2) { ["id"]=> string(1) "1" ["name"]=> string(5) "Foo" } [1]=> array(2) { ["id"]=> string(1) "2" ["name"]=> string(3) "Bar" } } } I simply want to extract the "id" and "name" keys below, to use in a view but I'm a little stumped. I've tried the suggestions below, but can't quite work it out. How to Flatten a

PayPal IPN simulator returning “INVALID” but I've followed the rules

点点圈 提交于 2019-11-30 09:52:30
问题 So I have a PHP service that's only job is to accept PayPal IPN connections. I'm using PSR7 $request->getBody()->getContents() to get the following from PayPal IPN simulator request. payment_type=echeck&payment_date=Tue%20Jun%2007%202016%2012%3A56%3A47%20GMT+0100%20%28BST%29&payment_status=Completed&address_status=confirmed&payer_status=verified&first_name=John&last_name=Smith&payer_email=buyer@paypalsandbox.com&payer_id=TESTBUYERID01&address_name=John%20Smith&address_country=United%20States

Guzzle ~6.0 multipart and form_params

左心房为你撑大大i 提交于 2019-11-30 08:51:22
I am trying to upload file and send post parameters at the same time like this: $response = $client->post('http://example.com/api', [ 'form_params' => [ 'name' => 'Example name', ], 'multipart' => [ [ 'name' => 'image', 'contents' => fopen('/path/to/image', 'r') ] ] ]); However my form_params fields are ignored and only the multipart fields are present in my post body. Can I send both at all with guzzle 6.0 ? Simon Crowfoot I ran into the same problem. You need to add your form_params to the multipart array. Where 'name' is the form element name and 'contents' is the value. The example code