@@ -70,22 +70,22 @@ private function __construct() {}
7070 * @see ReportUtils::DownloadReport
7171 */
7272 public static function DownloadReport ($ reportDefinition , $ path = null ,
73- AdWordsUser $ user , array $ options = null ) {
73+ AdWordsUser $ user , array $ options = null , array $ customCurlOptions = null ) {
7474 $ url = self ::GetUrl ($ user , $ options );
7575 $ headers = self ::GetHeaders ($ user , $ url , $ options );
7676 $ params = self ::GetParams ($ reportDefinition );
77- return self ::DownloadReportFromUrl ($ url , $ headers , $ params , $ path );
77+ return self ::DownloadReportFromUrl ($ url , $ headers , $ params , $ path, $ customCurlOptions );
7878 }
7979
8080 /**
8181 * @see ReportUtils::DownloadReportWithAwql
8282 */
8383 public static function DownloadReportWithAwql ($ reportQuery , $ path = null ,
84- AdWordsUser $ user , $ reportFormat , array $ options = null ) {
84+ AdWordsUser $ user , $ reportFormat , array $ options = null , array $ customCurlOptions = null ) {
8585 $ url = self ::GetUrl ($ user , $ options );
8686 $ headers = self ::GetHeaders ($ user , $ url , $ options );
8787 $ params = self ::GetQueryParams ($ reportQuery , $ reportFormat );
88- return self ::DownloadReportFromUrl ($ url , $ headers , $ params , $ path );
88+ return self ::DownloadReportFromUrl ($ url , $ headers , $ params , $ path, $ customCurlOptions );
8989 }
9090
9191 /**
@@ -98,7 +98,7 @@ public static function DownloadReportWithAwql($reportQuery, $path = null,
9898 * otherwise the size in bytes of the downloaded report
9999 */
100100 private static function DownloadReportFromUrl ($ url , $ headers , $ params ,
101- $ path = null ) {
101+ $ path = null , $ customCurlOptions = null ) {
102102 /*
103103 * This method should not be static and instantiation of this class should
104104 * be allowed so we can "inject" CurlUtils, but would break too many things
@@ -126,6 +126,13 @@ private static function DownloadReportFromUrl($url, $headers, $params,
126126 $ curlUtils ->SetOpt ($ ch , CURLOPT_FILE , $ file );
127127 }
128128
129+ ## sometimes need to set some useful curl options. example: $customCurlOptions = ['CURLOPT_TIMEOUT' => 1];
130+ if (!empty ($ customCurlOptions )) {
131+ foreach ($ customCurlOptions as $ curlOption => $ curlValue ) {
132+ $ curlUtils ->SetOpt ($ ch , $ curlOption , $ curlValue );
133+ }
134+ }
135+
129136 $ response = $ curlUtils ->Exec ($ ch );
130137 $ error = $ curlUtils ->Error ($ ch );
131138 $ code = $ curlUtils ->GetInfo ($ ch , CURLINFO_HTTP_CODE );
0 commit comments