1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright 2015 Dirk Groenen |
4
|
|
|
* |
5
|
|
|
* (c) Dirk Groenen <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace DirkGroenen\Pinterest\Endpoints; |
12
|
|
|
|
13
|
|
|
use DirkGroenen\Pinterest\Models\Pin; |
14
|
|
|
use DirkGroenen\Pinterest\Models\Collection; |
15
|
|
|
|
16
|
|
|
class Pins extends Endpoint { |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Get a pin object |
20
|
|
|
* |
21
|
|
|
* @access public |
22
|
|
|
* @param string $pin_id |
23
|
|
|
* @param array $data |
24
|
|
|
* @throws Exceptions/PinterestExceptions |
25
|
|
|
* @return Pin |
26
|
|
|
*/ |
27
|
3 |
|
public function get($pin_id, array $data = []) |
28
|
|
|
{ |
29
|
3 |
|
$response = $this->request->get(sprintf("pins/%s", $pin_id), $data); |
30
|
3 |
|
return new Pin($this->master, $response); |
|
|
|
|
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Get all pins from the given board |
35
|
|
|
* |
36
|
|
|
* @access public |
37
|
|
|
* @param string $board_id |
38
|
|
|
* @param array $data |
39
|
|
|
* @throws Exceptions/PinterestExceptions |
40
|
|
|
* @return Collection |
41
|
|
|
*/ |
42
|
1 |
|
public function fromBoard($board_id, array $data = []) |
43
|
|
|
{ |
44
|
1 |
|
$response = $this->request->get(sprintf("boards/%s/pins", $board_id), $data); |
45
|
1 |
|
return new Collection($this->master, $response, "Pin"); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Create a pin |
50
|
|
|
* |
51
|
|
|
* @access public |
52
|
|
|
* @param array $data |
53
|
|
|
* @throws Exceptions/PinterestExceptions |
54
|
|
|
* @return Pin |
55
|
|
|
*/ |
56
|
1 |
|
public function create(array $data) |
57
|
|
|
{ |
58
|
1 |
|
if (array_key_exists("image", $data)) { |
59
|
|
|
if (class_exists("\CURLFile")) { |
60
|
|
|
$data["image"] = new \CURLFile($data['image']); |
61
|
|
|
} else { |
62
|
|
|
$data["image"] = '@' . $data['image']; |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|
66
|
1 |
|
$response = $this->request->post("pins", $data); |
67
|
1 |
|
return new Pin($this->master, $response); |
|
|
|
|
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Update a pin |
72
|
|
|
* |
73
|
|
|
* @access public |
74
|
|
|
* @param string $pin_id |
75
|
|
|
* @param array $data |
76
|
|
|
* @throws Exceptions/PinterestExceptions |
77
|
|
|
* @return Pin |
78
|
|
|
*/ |
79
|
1 |
|
public function update($pin_id, array $data) |
80
|
1 |
|
{ |
81
|
|
|
$response = $this->request->update(sprintf("pins/%s", $pin_id), $data); |
82
|
|
|
return new Pin($this->master, $response); |
|
|
|
|
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Delete a pin |
87
|
|
|
* |
88
|
|
|
* @access public |
89
|
|
|
* @param string $pin_id |
90
|
|
|
* @throws Exceptions/PinterestExceptions |
91
|
|
|
* @return boolean |
92
|
|
|
*/ |
93
|
1 |
|
public function delete($pin_id) |
94
|
|
|
{ |
95
|
1 |
|
$this->request->delete(sprintf("pins/%s", $pin_id)); |
96
|
1 |
|
return true; |
97
|
|
|
} |
98
|
|
|
} |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: