Skip to content

Instantly share code, notes, and snippets.

if(count($parsed_response->feed->data)>0) {
## Now, after we've already used the empty variable $max_id
# $max_id = $parsed_response->statuses->data[0]->updated_time;
//echo "The max_id_str should be : " . $parsed_response->max_id_str;
$max_id = date("Y-m-d\TH:i:s\Z", strtotime($parsed_response->feed->data[0]->created_time));
update_option('fbp_max_status_id', $max_id);
echo $max_id;
// print_r($parsed_response->statuses->data);
$statusesray = $parsed_response->feed->data;
// var_dump($statusesray);
{
   "id": "XXXXX",
   "feed": {
      "data": [
         {
            "from": {
               "category": "Amateur sports team",
               "category_list": [
                  {
                     "id": "1803",
statusarray(1) { [0]=> object(stdClass)#355 (5) { ["from"]=> object(stdClass)#357 (4) { ["category"]=> string(19) "Amateur sports team" ["category_list"]=> array(1) { [0]=> object(stdClass)#359 (2) { ["id"]=> string(4) "1803" ["name"]=> string(19) "Amateur Sports Team" } } ["name"]=> string(17) "Running Dead Team" ["id"]=> string(15) "381512695217333" } ["id"]=> string(31) "381512695217333_506095169425751" ["message"]=> string(109) "Next sunday is going to be bitter sweet for us Walking Dead fans! A great finale.. but a finale none the less" ["type"]=> string(6) "status" ["created_time"]=> string(24) "2013-03-27T02:33:43+0000" } }
foreach($statusesray as $status)
{
if($status->type=="status")
{
do stuff
}
// this echos "photo" which is expected when the type == photo
echo $status->type;
// Schedules an event
function fbp_create_schedule2() {
global $fbp_opts;
$recurrence = isset($fbp_opts['recurrence']) ? $fbp_opts['recurrence'] : 'hourly';
$schedule = wp_get_schedule('fbp_statuses_to_posts');
$author_id = isset($fbp_opts['author']) ? $fbp_opts['author'] : 0;
$author = get_user_by('id', $author_id);
// Clear the schedule if recurrence was changed
if($schedule != $recurrence) {
wp_clear_scheduled_hook('fbp_statuses_to_posts');
<ul id="menu-main-nav" class="nav-menu"><li id="nav-menu-item-17" class="main-menu-item menu-item-even menu-item-depth-0 about menu-item menu-item-type-post_type menu-item-object-page"><a href="http://nsr.dev/about-us/" data-description="Our Story" class="menu-link main-menu-link">About Us</a><small class="nav_desc">Our Story</small>
<ul class="sub-menu menu-odd menu-depth-1">
<li id="nav-menu-item-34" class="sub-menu-item menu-item-odd menu-item-depth-1 menu-item menu-item-type-post_type menu-item-object-page"><a href="http://nsr.dev/about-us/about-sub-page/" class="menu-link sub-menu-link">History</a></li>
<li id="nav-menu-item-32" class="sub-menu-item menu-item-odd menu-item-depth-1 menu-item menu-item-type-post_type menu-item-object-page"><a href="http://nsr.dev/about-us/values-mission/" class="menu-link sub-menu-link">Values &amp; Mission</a></li>
<li id="nav-menu-item-33" class="sub-menu-item menu-item-odd menu-item-depth-1 menu-item menu-item-type-post_type menu-item-object-page"><a href="http
class description_walker extends Walker_Nav_Menu
{
/**
* Start the element output.
*
* @param string $output Passed by reference. Used to append additional content.
* @param object $item Menu item data object.
* @param int $depth Depth of menu item. May be used for padding.
* @param array $args Additional strings.
@LinzardMac
LinzardMac / gist:5103629
Created March 6, 2013 22:18
Adding a link that gets the recent post from a CPT and putting it in a specified menu
// Filter wp_nav_menu() to add link to recent lottery
function new_nav_menu_items($items) {
// Get the most recent post
$the_query = new WP_Query( 'post_type=toy_lotteries' , 'posts_per_page=1' );
// Pull the link
while ( $the_query->have_posts() ) : $the_query->the_post();
$latest_link = '<li> <a href="' . get_permalink() . '">Lotteries</a></li>';
endwhile;
$items = $latest_link . $items;
return $items;
// Filter wp_nav_menu() to add link to recent lottery
function new_nav_menu_items($items) {
// Get the most recent post
$the_query = new WP_Query( 'posts_per_page=1' );
// Pull the excerpt
while ( $the_query->have_posts() ) : $the_query->the_post();
$latest_link = '<li> <a href="' . get_permalink() . '>Lotteries</a></li>';
endwhile;
$items = $latest_link . $items;
return $items;
@LinzardMac
LinzardMac / PHP
Created February 17, 2013 23:17
Get the facebook access token
$catray[] = $categorize;
$access = file_get_contents('https://graph.facebook.com/oauth/access_token?type=client_cred&client_id=' . $clientid . '&client_secret=' . $clientsecret . '');
$token = str_replace('access_token=', '', $access);
// Fire the Hfbp request to Twitter
$response[] = 'https://graph.facebook.com/' . $pageid . '?fields=statuses.fields(from,id,message)&access_token='.$token;