我創建了一個非常簡單的小型php腳本,我希望能夠在我的MacOSX終端上的命令行中運行。php文件未在命令行中運行......但在本地主機上運行時工作
如果我只輸入echo "test"
即可得到輸出。
現在我向該腳本添加了一個curl請求,以從API獲取一些數據,然後鍵入print_r $result
。
不幸的是,結果永遠不會輸出到命令行中。如果我現在在我的MAMP本地主機上運行完全相同的php文件,一切工作正常,內容輸出正確。
這是我的代碼:
require 'connection.php';
$store = new connection('danny', 'https://store-bgf5e.mybigcommerce.com/api/v2/', 'XXXXX');
$customers = $store->get('/customers');
foreach($customers AS $customer) {
print "------ Getting Adresses for: " . $customer['first_name'] . ' ' . $customer['last_name'] . ' -------';
if(isset($customer['addresses']['resource'])) {
print_r($store->get($customer['addresses']['resource']));
}
}
exit;
我知道,API返回的地址就好了這樣的電話肯定能行。
這是捲曲的話說:
* Trying 63.141.159.120...
* TCP_NODELAY set
* Connected to store-bgf5e.mybigcommerce.com (63.141.159.120) port 443 (#0)
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
* CAfile: /Applications/MAMP/Library/OpenSSL/cert.pem CApath: none
* SSL connection using TLSv1.2/ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server accepted to use http/1.1
* Server certificate:
* subject: C=AU; ST=New South Wales; L=Ultimo; O=Bigcommerce Pty Ltd; CN=*.mybigcommerce.com
* start date: Jun 4 00:00:00 2015 GMT
* expire date: Sep 1 12:00:00 2018 GMT
* subjectAltName: host "store-bgf5e.mybigcommerce.com" matched cert's "*.mybigcommerce.com"
* issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert SHA2 High Assurance Server CA
* SSL certificate verify ok.
> GET /api/v2/customers HTTP/1.1
Host: store-bgf5e.mybigcommerce.com
Authorization: Basic ZGFubnk6M2QyNjE5NTdjZGNjMTNlYmU1MTJiNDRiMjE1NGJiZGZmMGRjNTUxMw==
Accept: application/json
Content-Type: application/json
< HTTP/1.1 200 OK
< Server: openresty
< Date: Fri, 05 May 2017 19:26:27 GMT
< Content-Type: application/json
< Transfer-Encoding: chunked
< Connection: keep-alive
< Set-Cookie: fornax_anonymousId=0ff167a5-e158-4ff8-8962-67b19bd4271b; expires=Mon, 03-May-2027 19:26:27 GMT; path=/; domain=.store-bgf5e.mybigcommerce.com
< Last-Modified: Thu, 13 Apr 2017 22:34:54 +0000
< X-BC-ApiLimit-Remaining: 2147483622
< X-BC-Store-Version: 7.6.0
<
* Curl_http_done: called premature == 0
* Connection #0 to host store-bgf5e.mybigcommerce.com left intact
對我來說,它看起來像捲曲被正確執行的一切。這幾乎就像成功的curl請求阻止任何其他PHP代碼運行。由於「print_r」,我希望看到地址被打印到命令行。
在此先感謝您提供的任何提示。
您需要發佈腳本。 – Barmar
代碼por。 –
更新了問題,對不起傢伙! – user3307277