@@ -365,7 +365,7 @@ public function setObeyRobots($bool = true)
365
365
366
366
return $ this ;
367
367
}
368
-
368
+
369
369
/**
370
370
* Set value to 1 to force the use of proxy IPs for the crawl.
371
371
*
@@ -450,10 +450,31 @@ public function delete($commit = true)
450
450
451
451
return ($ commit ) ? $ this ->call () : $ this ;
452
452
}
453
+ public function getCrawl ()
454
+ {
455
+ $ theUrl = $ this ->apiUrl ."?token= " . $ this ->diffbot ->getToken () . "&name= " . $ this ->name ;
456
+ $ response = $ this ->diffbot ->getHttpClient ()->get ($ theUrl );
457
+
458
+ $ array = json_decode ($ response ->getBody (), true );
459
+
460
+ if (isset ($ array ['jobs ' ])) {
461
+ $ jobs = [];
462
+ foreach ($ array ['jobs ' ] as $ job ) {
463
+ $ jobs [] = new JobCrawl ($ job );
464
+ }
465
+ return new EntityIterator ($ jobs , $ response );
466
+ } elseif (!isset ($ array ['jobs ' ]) && isset ($ array ['response ' ])) {
467
+ return $ array ['response ' ];
468
+ } else {
469
+ throw new DiffbotException ($ array ["error " ]);
470
+ }
471
+ }
453
472
454
473
public function call ()
455
474
{
456
- $ response = $ this ->diffbot ->getHttpClient ()->get ($ this ->buildUrl ());
475
+ $ theHeader =["content-type " =>"application/x-www-form-urlencoded; charset=UTF-8 " ];
476
+ $ response = $ this ->diffbot ->getHttpClient ()->post ($ this ->apiUrl , $ theHeader , $ this ->buildUrl ());
477
+
457
478
458
479
$ array = json_decode ($ response ->getBody (), true );
459
480
@@ -491,10 +512,9 @@ public function buildUrl()
491
512
unset($ this ->otherOptions ['urlCrawlPattern ' ]);
492
513
}
493
514
494
- $ url = rtrim ($ this ->apiUrl , '/ ' ) . '? ' ;
495
515
496
516
// Add token
497
- $ url . = 'token= ' . $ this ->diffbot ->getToken ();
517
+ $ url = 'token= ' . $ this ->diffbot ->getToken ();
498
518
499
519
if ($ this ->getName ()) {
500
520
// Add name
@@ -503,8 +523,8 @@ public function buildUrl()
503
523
// Add seeds
504
524
if (!empty ($ this ->seeds )) {
505
525
$ url .= '&seeds= ' . implode ('%20 ' , array_map (function ($ item ) {
506
- return urlencode ($ item );
507
- }, $ this ->seeds ));
526
+ return urlencode ($ item );
527
+ }, $ this ->seeds ));
508
528
}
509
529
510
530
// Add other options
@@ -523,7 +543,7 @@ public function buildUrl()
523
543
524
544
/**
525
545
* Sets the request type to "urls" to retrieve the URL Report
526
- * URL for understanding diagnostic data of URLs
546
+ * URL for understanding diagnostic data of URLs
527
547
*
528
548
* @return $this
529
549
*/
@@ -532,7 +552,7 @@ public function getUrlReportUrl($num = null)
532
552
$ this ->otherOptions ['type ' ] = 'urls ' ;
533
553
534
554
if (!empty ($ num ) && is_numeric ($ num )) {
535
- $ this ->otherOptions ['num ' ] = $ num ;
555
+ $ this ->otherOptions ['num ' ] = $ num ;
536
556
}
537
557
538
558
// Setup data endpoint
0 commit comments