Пример #1
0
function fts_pinterest_board_feed($atts)
{
    include_once ABSPATH . 'wp-admin/includes/plugin.php';
    extract(shortcode_atts(array('pinterest_name' => '', 'boards_count' => '1'), $atts));
    if (!empty($pinterest_name)) {
        $pinterest = new Pinterest();
        $pinterest->scrapeUser($pinterest_name);
        $pinterestFullBoards = $pinterest->getFullBoards();
        $i = 1;
        foreach ($pinterestFullBoards as $board) {
            if ($i <= $boards_count) {
                echo '<a class="fts-pin-board-wrap" href="' . $board['link'] . '" target="_blank">';
                echo '<h3 class="fts-pin-board-board_title">' . $board['board_title'] . '</h3>';
                echo '<div class="fts-pin-board-img-wrap"><span class="hoverMask"></span>';
                echo '<img class="fts-pin-board-cover" src="' . $board['cover'] . '"/>';
                echo '<div class="fts-pin-board-pin-count">' . $board['pin_count'] . '</div>';
                echo '</div>';
                echo '<div class="fts-pin-board-thumbs-wrap">';
                foreach ($board['thumbs'] as $key => $value) {
                    echo '<div class="pinterest-single-thumb-wrap"><span class="hoverMask"></span><img class="fts-pin-board-thumb" src="' . $value . '"/></div>';
                }
                echo '</div>';
                echo '</a>';
            }
            $i++;
        }
        echo '<div class="clear"></div>';
    } else {
        echo 'Please give a valid Pinterest UserName';
    }
}
Пример #2
0
}
?>

<div class="col-sm-offset-2 col-sm-5">

<form method="post" action="<?php 
$_SERVER['PHP_SELF'];
?>
" >
信義居家產品頁面網址:<input name="jurl" type="text" class="form-control" size="100"/><br/>
Pinterest Board<input name="board" type="text" size="30"/><br/>
<!--

<select name="board" class="form-control" >
<?php 
$p = new Pinterest();
$p->login("*****@*****.**", "sstc5202");
$p->get_boards();
foreach ($p->boards as $key => $val) {
    echo '<option value="' . $key . '">' . $key . '</option>' . "\n";
}
?>
</select>
-->
<input type="submit" value="轉檔" />
</form>
</div>

 
<?php 
include_once "footer.php";
Пример #3
0
 function get_gallery_image_from_source($source, $images = false, $lightbox_type)
 {
     $media = $return = array();
     global $be_themes_data;
     switch ($source['source']) {
         case 'instagram':
             $transient_var = 'transient_instagram_user_data_' . $source['account_name'] . '_' . $source['count'];
             $instagram_access_token = isset($be_themes_data['instagram_access_token']) && !empty($be_themes_data['instagram_access_token']) ? $be_themes_data['instagram_access_token'] : '336050189.5b9e1e6.b7004d62939049478de2390091d61b9e';
             $transient_media = get_transient($transient_var);
             if ($transient_media && isset($transient_media) && !empty($transient_media)) {
                 $media = unserialize($transient_media);
             } else {
                 $user_data = wp_remote_get('https://api.instagram.com/v1/users/search?q=' . $source['account_name'] . '&access_token=' . $instagram_access_token);
                 if (is_wp_error($user_data)) {
                     delete_transient($transient_var);
                     $return['error'] = '<b>' . __('Instagram Error : ', 'be-themes') . '</b>' . $user_data->error_message;
                     return $return;
                 } else {
                     $user_data = json_decode($user_data['body']);
                     $user_data_arr = $user_data->data;
                     foreach ($user_data_arr as $users) {
                         if ($users->username == $source['account_name']) {
                             $user_id = $users->id;
                             break;
                         }
                     }
                     if (isset($user_data->error_message) || !empty($user_data->error_message)) {
                         delete_transient($transient_var);
                         $return['error'] = '<b>' . __('Instagram Error : ', 'be-themes') . '</b>' . $user_data->error_message;
                         return $return;
                     }
                     if (isset($user_id) && !empty($user_id) && $user_id) {
                         $instagram_media = wp_remote_get('https://api.instagram.com/v1/users/' . $user_id . '/media/recent/?access_token=' . $instagram_access_token . '&count=' . $source['count']);
                         if (isset($instagram_media->error_message) || !empty($instagram_media->error_message)) {
                             delete_transient($transient_var);
                             $return['error'] = '<b>' . __('Instagram Error : ', 'be-themes') . '</b>' . $instagram_media->error_message;
                             return $return;
                         }
                         if ($instagram_media && isset($instagram_media) && !empty($instagram_media)) {
                             set_transient($transient_var, serialize($instagram_media), 60 * 60 * 24 * 2);
                             $media = $instagram_media;
                         }
                     }
                 }
             }
             if ($media && isset($media) && !empty($media)) {
                 $images = json_decode($media["body"]);
                 $images = $images->data;
                 foreach ($images as $key => $value) {
                     $temp_image_array = array();
                     $temp_image_array = array('thumbnail' => $value->images->standard_resolution->url, 'full_image_url' => $value->images->standard_resolution->url, 'mfp_class' => $lightbox_type == 'photoswipe' ? '' : 'mfp-image', 'caption' => !empty($value->caption->text) ? $value->caption->text : '', 'description' => !empty($value->caption->text) ? $value->caption->text : '', 'width' => $value->images->standard_resolution->width, 'height' => $value->images->standard_resolution->height, 'id' => '');
                     array_push($return, $temp_image_array);
                 }
             }
             return $return;
             break;
         case 'flickr':
             delete_transient('transient_flickr_user_data_' . $source['account_name'] . '_' . $source['count']);
             $transient_media = get_transient('transient_flickr_user_data_' . $source['account_name'] . '_' . $source['count']);
             if ($transient_media && isset($transient_media) && !empty($transient_media)) {
                 $media = unserialize($transient_media);
             } else {
                 $user_data = wp_remote_get('https://api.flickr.com/services/rest/?method=flickr.people.findByUsername&username='******'account_name'] . '&format=php_serial&api_key=85145f20ba1864d8ff559a3971a0a033');
                 $user_data = unserialize($user_data["body"]);
                 if (isset($user_data['stat']) && $user_data['stat'] == 'ok') {
                     if (isset($user_data["user"]["nsid"]) && !empty($user_data["user"]["nsid"]) && $user_data["user"]["nsid"]) {
                         $flickr_media = wp_remote_get('https://api.flickr.com/services/rest/?method=flickr.photos.search&user_id=' . $user_data["user"]["nsid"] . '&format=php_serial&api_key=85145f20ba1864d8ff559a3971a0a033&per_page=' . $source['count'] . '&page=1&extras=url_z,url_o');
                         $flickr_media = unserialize($flickr_media["body"]);
                         if (isset($flickr_media['stat']) && $flickr_media['stat'] == 'ok') {
                             set_transient('transient_flickr_user_data_' . $source['account_name'] . '_' . $source['count'], serialize($flickr_media), 60 * 60 * 1);
                             $media = $flickr_media;
                         } else {
                             $return['error'] = '<b>' . __('Flickr Error : ', 'be-themes') . '</b>' . __("Unknown Error", "be-themes");
                             return $return;
                         }
                     }
                 } else {
                     $return['error'] = '<b>' . __('Flickr Error : ', 'be-themes') . '</b>' . $user_data["message"];
                     return $return;
                 }
             }
             if ($media && isset($media) && !empty($media)) {
                 $images = $media['photos']['photo'];
                 foreach ($images as $key => $value) {
                     $temp_image_array = array();
                     $temp_image_array = array('thumbnail' => isset($value["url_z"]) && !empty($value["url_z"]) ? $value["url_z"] : $value["url_o"], 'full_image_url' => isset($value["url_z"]) && !empty($value["url_z"]) ? $value["url_z"] : $value["url_o"], 'mfp_class' => $lightbox_type == 'photoswipe' ? '' : 'mfp-image', 'caption' => !empty($value["title"]) ? $value["title"] : '', 'description' => !empty($value["title"]) ? $value["title"] : '', 'width' => isset($value["width_z"]) && !empty($value["width_z"]) ? $value["width_z"] : $value["width_o"], 'height' => isset($value["height_z"]) && !empty($value["height_z"]) ? $value["height_z"] : $value["height_o"], 'id' => '');
                     array_push($return, $temp_image_array);
                 }
             }
             return $return;
         case 'dribble':
             $transient_media = get_transient('transient_dribble_user_data_' . $source['account_name'] . '_' . $source['count']);
             if ($transient_media && isset($transient_media) && !empty($transient_media)) {
                 $media = unserialize($transient_media);
             } else {
                 $dribble_media = wp_remote_get('https://dribbble.com/' . $source['account_name'] . '/shots.json');
                 if (isset($dribble_media["response"]["message"]) && !empty($dribble_media["response"]["message"]) && $dribble_media["response"]["message"] == 'OK') {
                     $dribble_media = json_decode($dribble_media["body"]);
                     if ($dribble_media && isset($dribble_media) && !empty($dribble_media)) {
                         set_transient('transient_dribble_user_data_' . $source['account_name'] . '_' . $source['count'], serialize($dribble_media), 60 * 60 * 1);
                         $media = $dribble_media;
                     }
                 } else {
                     $return['error'] = '<b>' . __('Dribble Error : ', 'be-themes') . '</b>' . $dribble_media["response"]["message"];
                     return $return;
                 }
             }
             if ($media && isset($media) && !empty($media)) {
                 $images = $media->shots;
                 $i = 0;
                 foreach ($images as $key => $value) {
                     if ($i < $source['count']) {
                         $temp_image_array = array();
                         $temp_image_array = array('thumbnail' => $value->image_400_url, 'full_image_url' => $value->image_url, 'mfp_class' => $lightbox_type == 'photoswipe' ? '' : 'mfp-image', 'caption' => !empty($value->title) ? $value->title : '', 'description' => !empty($value->title) ? $value->title : '', 'width' => $value->width, 'height' => $value->height, 'id' => '');
                         array_push($return, $temp_image_array);
                         $i++;
                     }
                 }
             }
             return $return;
             break;
         case 'pintrest':
             require_once get_template_directory() . '/functions/Pintrest/Pinterest.class.php';
             $pinterest = new Pinterest($source['account_name']);
             $pinterest->itemsperpage = $source['count'];
             $pinsresult = $pinterest->getPins();
             foreach ($pinsresult["data"] as $pin) {
                 $bigimage = str_replace("237x", "736x", $pin->images->{'237x'}->url);
                 $temp_image_array = array();
                 $temp_image_array = array('thumbnail' => $bigimage, 'full_image_url' => $bigimage, 'mfp_class' => 'mfp-image', 'caption' => '', 'id' => '');
                 array_push($return, $temp_image_array);
             }
             return $return;
             break;
         default:
             if ($images) {
                 $images = explode(",", $images);
                 foreach ($images as $image) {
                     $temp_image_array = array();
                     $image_atts = get_portfolio_image($image, $source['col'], $source['masonry']);
                     $attachment_thumb = wp_get_attachment_image_src($image, $image_atts['size']);
                     $attachment_full = wp_get_attachment_image_src($image, 'full');
                     $attachment_thumb_url = $attachment_thumb[0];
                     $attachment_full_url = $attachment_full[0];
                     $video_url = get_post_meta($image, 'be_themes_featured_video_url', true);
                     $attachment_info = be_wp_get_attachment($image);
                     $mfp_class = $lightbox_type == 'photoswipe' ? '' : 'mfp-image';
                     if (!empty($video_url) && $lightbox_type != 'photoswipe') {
                         $attachment_full_url = $video_url;
                         $mfp_class = 'mfp-iframe';
                     }
                     $temp_image_array = array('thumbnail' => $attachment_thumb_url, 'full_image_url' => $attachment_full_url, 'mfp_class' => $mfp_class, 'caption' => $attachment_info['title'], 'description' => $attachment_info['description'], 'width' => $attachment_info['width'], 'height' => $attachment_info['height'], 'id' => $image);
                     array_push($return, $temp_image_array);
                 }
                 return $return;
             }
             break;
     }
 }
Пример #4
0
<?php

/* Require the Pinterest API class */
require_once 'lib/Pinterest.class.php';
$pins = [];
// Set users and their boards - not pretty
$users = ['electricsheep01', 'electricsheep01'];
$boards = ['firewatch', 'monument-valley'];
// Loop for each user/board
foreach ($users as $key => $user) {
    $pinterest = new Pinterest($user);
    $resp = $pinterest->getPinsFromBoard($boards[$key]);
    // Merge into one array
    $pins = array_merge($pins, $resp["data"]);
}
// Sort by most recent (using ID)
function compare($a, $b)
{
    return strcmp($a->id, $b->id);
}
usort($pins, "compare");
?>
<html>
    <head>
        <link rel="stylesheet" type="text/css" href="css/style.css">
    </head>
    <body>
        <ul>
        <?php 
foreach ($pins as $pin) {
    ?>
Пример #5
0
 public function delete_pin($pin_id)
 {
     // Can't do anything if we're not logged in
     if (!$this->is_logged_in) {
         return Pinterest::NOT_LOGGED_IN;
     }
     // OK!  We're ready!  Prepare the pin JSON
     $data_json = array("options" => array("id" => $pin_id), "context" => array());
     // Set up the "module path" data
     $module_path = "Modal()>ConfirmDialog(template=delete_pin, ga_category=pin_delete)";
     // And prepare the post data array
     $post = array("source_url" => "/pin/{$pin_id}/", "data" => json_encode($data_json, JSON_FORCE_OBJECT), "module_path" => urlencode($module_path));
     // Now make the post string
     $post_arr = array();
     foreach ($post as $k => $v) {
         $post_arr[] = "{$k}=" . urlencode($v);
     }
     $post_string = join("&", $post_arr);
     // Fix up parens
     $post_string = Pinterest::fix_encoding($post_string);
     // Now set up the CURL call
     $ch = \curl_init($this->delete_pin_url);
     \curl_setopt_array($ch, array(CURLOPT_COOKIEFILE => $this->cookie_jar, CURLOPT_USERAGENT => "Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0", CURLOPT_REFERER => "https://www.pinterest.com/pin/{$pin_id}/", CURLOPT_HTTPHEADER => array('Host: www.pinterest.com', 'Accept: application/json, text/javascript, */*; q=0.01', 'Accept-Language: en-US,en;q=0.5', 'DNT: 1', 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8', 'X-Pinterest-AppState: active', 'X-CSRFToken: ' . $this->csrf_token, 'X-NEW-APP: 1', 'X-APP-VERSION: 04cf8cc', 'X-Requested-With: XMLHttpRequest'), CURLOPT_POST => true, CURLOPT_POSTFIELDS => $post_string, CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false));
     // Run the CURL call
     $res = \curl_exec($ch);
     \curl_close($ch);
     $json = json_decode($res, TRUE);
     print_r($json);
     // If the result is json, we've succeeded!
     if ($json === null) {
         return Pinterest::UNABLE_TO_DELETE;
     } else {
         return Pinterest::SUCCESS;
     }
 }