seregazhuk\PinterestBot\Api\Providers\Pins::create PHP Method

create() public method

Create a pin. Returns created pin info.
public create ( string $imageUrl, integer $boardId, string $description = '', string $link = '' ) : array
$imageUrl string
$boardId integer
$description string
$link string
return array
    public function create($imageUrl, $boardId, $description = '', $link = '')
    {
        // Upload image if first argument is not url
        if (!filter_var($imageUrl, FILTER_VALIDATE_URL)) {
            $imageUrl = $this->upload($imageUrl);
        }
        $requestOptions = ['method' => 'scraped', 'description' => $description, 'link' => empty($link) ? $imageUrl : $link, 'image_url' => $imageUrl, 'board_id' => $boardId];
        return $this->execPostRequest($requestOptions, UrlBuilder::RESOURCE_CREATE_PIN, true)->getResponseData();
    }

Usage Example

Esempio n. 1
0
 /** @test */
 public function it_should_upload_images_when_creating_pin_with_local_image()
 {
     $image = 'image.jpg';
     $this->request->shouldReceive('upload')->withArgs([$image, UrlBuilder::IMAGE_UPLOAD])->andReturn(json_encode(['success' => true, 'image_url' => 'http://example.com/example.jpg']));
     $this->apiShouldCreatePin();
     $this->provider->create($image, 1, 'test');
 }
All Usage Examples Of seregazhuk\PinterestBot\Api\Providers\Pins::create