Skip to content
This repository has been archived by the owner on Jul 15, 2019. It is now read-only.

Commit

Permalink
further changing how insertUpdate works. much better
Browse files Browse the repository at this point in the history
  • Loading branch information
zagraves committed Jun 14, 2010
1 parent 13cc96f commit 944b2bc
Showing 1 changed file with 11 additions and 26 deletions.
37 changes: 11 additions & 26 deletions lib/Yahoo/YahooOAuthApplication.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,40 +372,25 @@ public function getUpdates($guid = null, $offset = 0, $limit = 10)
return isset($rsp->query->results) ? $rsp->query->results : false;
}

public function insertUpdate($guid = null, $description, $title, $link, $image = null, &$suid = null)
public function insertUpdate($guid = null, $params)
{
if($guid == null && !is_null($this->token))
{
$guid = $this->token->yahoo_guid;
}

if($suid == null)
{
// $suid = 'ugc'.rand(0, 1000);
$suid = uniqid(mt_rand());
}

$source = 'APP.'.$this->application_id;
$pubDate = time();

$update = array(
'guid' => $guid,
'title' => $title,
'description' => $description,
'link' => $link,
'pubDate' => $pubDate,
'source' => $source,
'suid' => $suid
$defaults = array(
'guid' => $guid,
'suid' => uniqid(mt_rand()),
'pubDate' => time(),
'source' => 'APP.'.$this->application_id,
'type' => 'appActivity',
'link' => ''
);

if($image) {
$update['imageURL'] = $image['url'];
$update['imageWidth'] = $image['width'];
$update['imageHeight'] = $image['height'];
}

$keys = implode(",", array_keys($update));
$values = implode(",", array_map('_yql_insert_quotes', array_values($update)));
$update = array_merge($defaults, $params);
$keys = implode(',', array_keys($update));
$values = implode(',', array_map('_yql_insert_quotes', array_values($update)));

$query = 'INSERT INTO social.updates (%s) VALUES (%s);';
$query = sprintf($query, $keys, $values);
Expand Down

0 comments on commit 944b2bc

Please sign in to comment.