How to perform multiple Guzzle requests at the same time?

From the docs: http://guzzle3.readthedocs.org/http-client/client.html#sending-requests-in-parallel For an easy to use solution that returns a hash of request objects mapping to a response or error, see http://guzzle3.readthedocs.org/batching/batching.html#batching Short example: <?php $client->send(array( $client->get(‘http://www.example.com/foo’), $client->get(‘http://www.example.com/baz’), $client->get(‘http://www.example.com/bar’) ));

How can I send SOAP XML via Curl and PHP?

Thanx a lot buddy, your code has worked for me. Here is the code: $soap_do = curl_init(); curl_setopt($soap_do, CURLOPT_URL, $url ); curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($soap_do, CURLOPT_TIMEOUT, 10); curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true ); curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($soap_do, CURLOPT_POST, true ); curl_setopt($soap_do, CURLOPT_POSTFIELDS, $post_string); curl_setopt($soap_do, CURLOPT_HTTPHEADER, array(‘Content-Type: text/xml; charset=utf-8’, ‘Content-Length: ‘.strlen($post_string) )); curl_setopt($soap_do, CURLOPT_USERPWD, $user … Read more

PayPal Transaction Search API: PERMISSION_DENIED, No Permission for the requested operation

You need the scope https://uri.paypal.com/services/reporting/search/read .. if it’s not there in the oauth2 response, double check your REST App’s permissions. Refreshing an access token Existing access tokens are cached for 9 hours–so if you already requested an API token and then just added this permission to your app, it can take up to 9 hours … Read more

PHP cURL: how to set body to binary data?

You can just set your body in CURLOPT_POSTFIELDS. Example: $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, “http://url/url/url” ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt($ch, CURLOPT_POST, 1 ); curl_setopt($ch, CURLOPT_POSTFIELDS, “body goes here” ); curl_setopt($ch, CURLOPT_HTTPHEADER, array(‘Content-Type: text/plain’)); $result=curl_exec ($ch); Taken from here Of course, set your own header type, and just do file_get_contents(‘/path/to/file’) for body.

download a file from ftp using curl and php

My guess is that your URL is pointing towards a directory, not a file. You would need to feed CURLOPT_URL the full URL to the file. Also if you want to download a file you might want to save it somewhere. Working example: $curl = curl_init(); $file = fopen(“ls-lR.gz”, ‘w’); curl_setopt($curl, CURLOPT_URL, “ftp://ftp.sunet.se/ls-lR.gz”); #input curl_setopt($curl, … Read more

PHP cURL, POST JSON

The bit that is the problem is: curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(“{categoryId: $fieldString}”)); CURLOPT_POSTFIELDS will accept either an array of parameters, or a URL-encoded string of parameters: curl_setopt($ch, CURLOPT_POSTFIELDS, array(‘json’=>json_encode($stuff))); curl_setopt($ch, CURLOPT_POSTFIELDS, ‘json=’.urlencode(json_encode($stuff))); Where json will be the name of the POST field (i.e.: will result in $_POST[‘json’] being accessible).