Permalink
Browse files

updated wording, yql use

  • Loading branch information...
1 parent cb4214c commit 26a4185182c72c1dbdc3679e10173f75fe047dec @zagraves zagraves committed Jan 26, 2010
Showing with 37 additions and 37 deletions.
  1. +8 −4 yupdates_hooks.php
  2. +15 −11 yupdates_options.php
  3. +14 −22 yupdates_utils.php
View
@@ -59,18 +59,22 @@ function yupdates_publish_post($postid)
}
$title_template = get_option("yupdates_title_template");
- $title_patterns = array('/#blog_title/', '/#blog_name/');
+ $title_patterns = array('/%blog_title%/', '/%blog_name%/');
$title_replacements = array($post->post_title, get_bloginfo("name"));
$update = new stdclass();
$update->title = preg_replace($title_patterns, $title_replacements, $title_template);
- $update->description = substr($post->post_content, 0, 256);
+ $update->description = substr($post->post_excerpt, 0, 256);
$update->link = $permalink;
- $response = $session->application->insertUpdate(null, $update->description, $update->title, $update->link);
+ $rsp = $session->application->insertUpdate(null, $update->description, $update->title, $update->link);
+
+ // $query = "INSERT INTO social.updates (guid, title, description, link, pubDate, source, suid) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s');";
+ // $query = sprintf($query, $guid, $update->title, $update->description, $update->link, $pubDate, $source, $suid);
+ // $response = $session->application->yql($query);
// todo: do better error handling
- if(is_null($response)) {
+ if(is_null($rsp)) {
error_log("Failed to generate Yahoo! Update for blog post.");
}
} else {
View
@@ -41,7 +41,9 @@
if (!defined( 'WP_PLUGIN_URL')) define('WP_PLUGIN_URL', WP_CONTENT_URL. '/plugins' );
if (!defined( 'WP_PLUGIN_DIR')) define('WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' );
-define('YUPDATES_DEFAULT_TITLE_TEMPLATE', "posted '#blog_title' on their WordPress blog '#blog_name'");
+define('YUPDATES_DEFAULT_TITLE_TEMPLATE', "posted '%blog_title%' on their WordPress blog '%blog_name%'");
+define('YUPDATES_EXTAUTH_HOST', "http://soldsomeheat-vm0.corp.yahoo.com/projects/extAuth");
+define('YUPDATES_EXTAUTH_DEFAULT_SCOPES', "yurw");
function yupdates_plugin_options() {
$session = yupdates_get_session();
@@ -53,13 +55,13 @@ function yupdates_plugin_options() {
$has_application = ($consumer_key && $consumer_secret && $appid);
- // extAuth options
+ // extAuth application options
$extAuth_host = $_SERVER["HTTP_HOST"];
$extAuth_application_url = get_bloginfo('wpurl');
$extAuth_title = get_bloginfo('name');
$extAuth_description = get_bloginfo('description');
$extAuth_third_party = $extAuth_host;
- $extAuth_scopes = 'yurw';
+ $extAuth_scopes = YUPDATES_EXTAUTH_DEFAULT_SCOPES;
$extAuth_return_to_url = sprintf("%s/plugins/yupdates_wordpress/yupdates_application.php", WP_CONTENT_URL);
$extAuth_favicon_url = sprintf("http://%s/favicon.ico", $extAuth_host);
@@ -84,11 +86,11 @@ function yupdates_plugin_options() {
<p>We've filled in the required fields below, click 'Create Application' below to submit.</p>
<div id="yupdates_app_setup">
<? else: ?>
- <p>Hey, it looks like you've already set up your blog with Yahoo! Updates. Awesome! <a onclick="switchDisplay('yupdates_app_setup');" title="Switch the Menu">Here's the form</a> in case you need it again.</p>
+ <p>Hey, it looks like you've already set up your blog with Yahoo! Updates, awesome! <a onclick="switchDisplay('yupdates_app_setup');" title="Switch the Menu">Here's the form</a> if you'd like to update the application.</p>
<div id="yupdates_app_setup" style="display:none;">
<? endif; ?>
- <form method="post" action="http://soldsomeheat-vm0.corp.yahoo.com/projects/extAuth" id="yahoo_extAuthForm" name="yahoo_extAuthForm" target="yahoo_extAuthWindow">
+ <form method="POST" action="<?php echo YUPDATES_EXTAUTH_HOST; ?>" id="yahoo_extAuthForm" name="yahoo_extAuthForm" target="yahoo_extAuthWindow">
<table class="form-table">
<tr valign="top">
<th scope="row">Blog Name</th>
@@ -100,21 +102,23 @@ function yupdates_plugin_options() {
</tr>
<tr valign="top">
<th scope="row">Favicon URL</th>
- <td><input type="text" size="35" name="favicon" value="<?php echo $extAuth_favicon_url; ?>" /></td>
+ <td><input type="text" size="35" name="favicon" value="<?php echo $extAuth_favicon_url; ?>" />
+ <br/><small>.ico files may not render correctly in IE</small></td>
</tr>
</table>
+
<input type="hidden" name="third_party" value="<?php echo $extAuth_third_party; ?>"/>
<input type="hidden" name="return_to" value="<?php echo $extAuth_return_to_url; ?>"/>
<input type="hidden" name="scopes" value="<?php echo $extAuth_scopes; ?>"/>
<input type="hidden" name="application_url" value="<?php echo $extAuth_application_url ?>">
<input type="hidden" name="domain" value="<?php echo $extAuth_host ?>">
+ <input type="hidden" name="appid" value="<?php echo $appid; ?>"/>
- <p id="createApp" class="submit"><input type="submit" name="Submit" value="<?php _e('Create Application') ?>"/></p>
+ <p id="createApp" class="submit"><input type="submit" name="Submit" value="<?php ($appid) ? _e('Update Application') : _e('Create Application') ?>"/></p>
</form>
</div>
<hr noshade="noshade" />
-
<a name="settings"></a>
<h3 class="authTitle">Yahoo! Updates Settings</h3>
@@ -125,12 +129,13 @@ function yupdates_plugin_options() {
<td>&lt;Your Yahoo! name&gt;<input type="text" size="50" name="yupdates_title_template" value="<?php echo $title_template; ?>" />
<br /><small>Use the following tags in the display field above:</small><br />
<ul>
- <li><small>"#blog_title" = the title of your blog post</small></li>
- <li><small>"#blog_name" = the name of your blog (i.e. "<?php bloginfo('name'); ?>")</small></li>
+ <li><small>"%blog_title%" = the title of your blog post</small></li>
+ <li><small>"%blog_name%" = the name of your blog (i.e. "<?php echo $extAuth_title; ?>")</small></li>
</ul>
</td>
</tr>
</table>
+
<hr noshade="noshade" />
<h3 class="authTitle">bit.ly Settings (optional)</h3>
@@ -155,7 +160,6 @@ function yupdates_plugin_options() {
<input type="hidden" id="yupdates_consumer_key" name="yupdates_consumer_key" value="<?php echo $consumer_key; ?>"/>
<input type="hidden" id="yupdates_consumer_secret" name="yupdates_consumer_secret" value="<?php echo $consumer_secret; ?>"/>
<input type="hidden" id="yupdates_application_id" name="yupdates_application_id" value="<?php echo $appid; ?>"/>
-
<input type="hidden" name="action" value="update" />
<input type="hidden" name="page_options" value="yupdates_consumer_key,yupdates_consumer_secret,yupdates_application_id,yupdates_title_template,yupdates_bitly_apiKey,yupdates_bitly_login" />
<?php if(function_exists("wp_nonce_field")) wp_nonce_field('update-options'); ?>
View
@@ -125,7 +125,7 @@ function yupdates_clear_session()
}
*/
- header(sprintf("Location: %s", get_bloginfo('url'));
+ header(sprintf("Location: %s", get_bloginfo('url')));
exit();
}
@@ -189,27 +189,19 @@ function yupdates_get_bitly_options()
function yupdates_bitly_shorten($permalink, $apiKey, $login)
{
- $base_url = "http://api.bit.ly/shorten";
- $params = array(
- 'apiKey' => $apiKey,
- 'login' => $login,
- 'longUrl' => $permalink,
- 'version' => '2.0.1',
- 'history' => '1'
- );
-
- $http = YahooCurl::fetch($base_url, $params);
-
- $rsp = $http["response_body"];
- $data = json_decode($rsp);
-
- if($data && $data->statusCode == "OK" && isset($data->results)) {
- $results = get_object_vars($data->results);
- $site = $results[$permalink];
-
- if($site && isset($site->shortUrl)) {
- $shortUrl = $site->shortUrl;
- return $shortUrl;
+ $query = "SELECT statusCode, results FROM bit.ly.shorten where login='%s' and apiKey='%s' and longUrl='%s' and history='1'";
+ $query = sprintf($query, $login, $apiKey, $permalink);
+
+ $session = yupdates_get_session();
+ $rsp = $session->application->yql($query);
+
+ $bitly = $rsp->query->results->bitly;
+
+ if($bitly && $bitly->statusCode == 'OK' && isset($bitly->results)) {
+ $results = $bitly->results->nodeKeyVal;
+
+ if($results && isset($results->shortUrl)) {
+ return $results->shortUrl;
}
}

0 comments on commit 26a4185

Please sign in to comment.