function do_step($from, $to) { global $facebook; global $canvas_url; $conn = get_db_conn(); mysql_query('INSERT INTO footprints SET `from`=' . $from . ', `time`=' . time() . ', `to`=' . $to, $conn); $prints = get_prints($to); try { // Set Profile FBML $fbml = render_profile_action($to, count($prints)) . render_profile_box($to, $prints); $facebook->api_client->profile_setFBML($fbml, $to); // Send notification email $send_email_url = $facebook->api_client->notifications_send($to, ' stepped on you. ' . '<a href="' . $canvas_url . '/footprints/">See all your Footprints</a>.', '<fb:notif-subject>You have been stepped on...</fb:notif-subject>' . ' stepped on you. <a href="' . $canvas_url . '/footprints/">See all your Footprints</a>.'); // Publish feed story $feed_title = '<fb:userlink uid="' . $from . '" shownetwork="false"/> stepped on <fb:name uid="' . $to . '"/>.'; $feed_body = 'Check out <a href="' . $canvas_url . '/footprints/?to=' . $to . '">' . '<fb:name uid="' . $to . '" firstnameonly="true" possessive="true"/> Footprints</a>.'; $facebook->api_client->feed_publishActionOfUser($feed_title, $feed_body); } catch (Exception $e) { error_log($e->getMessage()); } if (isset($send_email_url) && $send_email_url) { $facebook->redirect($send_email_url . '&next=' . urlencode('?to=' . $to) . '&canvas'); } return $prints; }
function do_step($from, $to) { global $facebook; $conn = get_db_conn(); mysql_query('INSERT INTO footprints SET `from`=' . $from . ', `time`=' . time() . ', `to`=' . $to, $conn); $prints = get_prints($to); try { // Set Profile FBML $fbml = render_profile_action($to, count($prints)) . render_profile_box($to, $prints); // start batch operation $facebook->api_client->begin_batch(); $facebook->api_client->profile_setFBML($fbml, $to); // Send notification // Notice the use of reference '&' $result =& $facebook->api_client->notifications_send($to, ' stepped on you. ' . '<a href="http://apps.facebook.com/footprints/">See all your Footprints</a>.'); // Publish feed story $feed_title = '<fb:userlink uid="' . $from . '" shownetwork="false"/> stepped on <fb:name uid="' . $to . '"/>.'; $feed_body = 'Check out <a href="http://apps.facebook.com/footprints/?to=' . $to . '">' . '<fb:name uid="' . $to . '" firstnameonly="true" possessive="true"/> Footprints</a>.'; $facebook->api_client->feed_publishActionOfUser($feed_title, $feed_body); // End batch operation. This will actually send queued API call to Facebook in // a single HTTP request $facebook->api_client->end_batch(); } catch (Exception $e) { error_log($e->getMessage()); } return $prints; }
function update_profile_box($user) { global $facebook; $facebook->api_client->profile_setFBML(render_profile_box($user), $user); }