UPDATED

Pinterest Search Api (Unofficial) - PHP.

Search Images and Pins from Pinterest using curl and PHP function. This is for Education purposes only


0 contributions

289 Views 1
 
 Tags    #tech(9)  

Simple PHP function you can use to extract images from Pinterest from a search query.

public function searchPinterest($q)
{
    $url = "https://in.pinterest.com/search/pins/?q=$q";

    $html = file_get_contents($url);

    $domd = new \DOMDocument();
    libxml_use_internal_errors(true);
    $domd->loadHTML($html);
    libxml_use_internal_errors(false);

    $items = $domd->getElementsByTagName('script');
    $data = array();

    foreach ($items as $item) {
        $data[] = [
            'src' => $item->getAttribute('src'),
            'outerHTML' => $domd->saveHTML($item),
            'innerHTML' => $domd->saveHTML($item->firstChild),
        ];
    }

    foreach ($data as $key => $value) {
        $response = json_decode($value['innerHTML']);
        if (!$response) {
            continue;
        }
        if (isset($response->tree->data->results)) {
            foreach ($response->tree->data->results as $obj) {
                print_r($obj->like_count);
                $images = (Array) $obj->images;
                print_r($images['736x']->url);

            }
        }
    }
}


Please login before Adding Contribution

LOGIN


Input Item is required

{{value.error}} Invalid Url Found


{{value.title}}

{{value.description}}

Source:{{value.url}}
{{value.error}} {{value.serror}} Input Item is Required





Source:{{value.cite}}





{{value.error}} Input Item is Required



Instagram Logo
{{value.error}} Input Item is Required



{{value.error}} {{value.serror}} Input Item is Required





{{value.snippet.title}}

{{value.snippet.description|truncate:'20':'...'}} {{value.snippet.channelTitle}}
Views {{value.statistics.viewCount|number}}


Preview will appear here..
No Gifs Found