Skip to content

Instantly share code, notes, and snippets.

@jgraup
Last active October 3, 2022 11:00
Show Gist options
  • Save jgraup/7627862 to your computer and use it in GitHub Desktop.
Save jgraup/7627862 to your computer and use it in GitHub Desktop.
PHP - Unity3D Asset Store Publisher Feed. You must supply your own secret key to use this, a key is generated per publisher at https://publisher.assetstore.unity3d.com/info.html
<?php
include_once ( 'unity3d-assetstore.php' );
// Doesn't matter what is used for the publisher name,
// the key still points to only one publisher.
$authArray = array (
'publisher' => '{PUBLISHER_NAME}'
'key' => '{PUBLISHER_KEY}',
);
$data = Unity3DAssetStore::getPublisherFeed($authArray['key'], $authArray['publisher']);
/**
* @var $node SimpleXMLElement
* @var $feed SimpleXMLElement
* @var $channel SimpleXMLElement
*/
@$feed = new SimpleXMLElement($data);
@$channel = $feed->xpath('channel')[0];
// var_dump($feed);
echo "Channel\n\t";
echo "title: ", $channel->xpath("title")[0], "\n\t";
echo "link: ", $channel->link, "\n\t";
echo "description: ", $channel->description, "\n\t";
echo "language: ", $channel->language, "\n\t";
echo "copyright: ", $channel->copyright, "\n\t";
echo "pubDate: ", $channel->pubDate, "\n\t";
echo "ttl: ", $channel->ttl, "\n\t";
echo "image: ", $channel->xpath("image/url")[0], "\n\t";
echo "\n";
$items = $feed->xpath('channel/item');
while(list( , $node) = each($items)) {
echo 'title: ', $node->title, "\n\t";
echo 'link: ', $node->link, "\n\t";
echo 'description: ', $node->description, "\n\t";
echo 'guid: ', $node->guid, "\n\t";
echo 'pubDate: ', $node->pubDate, "\n";
echo "\n";
}
<?php
/**
* Unity3DAssetStore Class
*/
class Unity3DAssetStore
{
/**
* static @var $PUBLISHER_API_FEED_URL string Base url for publisher feeds
* static @var $PUBLISHER_API_FEED_ACTIVITY string
* static @var $XSL_BEFORE string
* static @var $XSL_AFTER string
*/
public static $PUBLISHER_API_FEED_URL = 'https://publisher.assetstore.unity3d.com/feed/';
public static $PUBLISHER_API_FEED_ACTIVITY = '/activity.rss';
public static $XSL_BEFORE = '"/resources/xsl/rss/activity.xsl"';
public static $XSL_AFTER = '"https://publisher.assetstore.unity3d.com/resources/xsl/rss/activity.xsl"';
/**
* @param $key
* @param string $publisher (Optional)
* @return string Feed Data
*/
public static function getPublisherFeed($key, $publisher = "")
{
if ( $publisher === "" || strlen($publisher) < 1 ) $publisher = "publisher";
$apiUrl = Unity3DAssetStore::$PUBLISHER_API_FEED_URL . $publisher . "/" . $key . Unity3DAssetStore::$PUBLISHER_API_FEED_ACTIVITY;
$data = @file_get_contents($apiUrl);
return ($data)
? str_replace (Unity3DAssetStore::$XSL_BEFORE, Unity3DAssetStore::$XSL_AFTER, $data)
: $data;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="/resources/xsl/rss/activity.xsl"?>
<rss version="2.0"
xmlns:blogChannel="http://backend.userland.com/blogChannelModule"
>
<channel>
<title>Unity Asset Store - Latest activity for Just Good Design</title>
<link>http://u3d.as/3sY</link>
<description>The latest activity for Just Good Design in the Unity Asset Store.</description>
<language>en-us</language>
<copyright>Unity Technologies</copyright>
<pubDate>Sun, 24 Nov 2013 14:20:09 -0000</pubDate>
<ttl>10</ttl>
<image>
<title>Unity</title>
<url>http://download.unity3d.com/images/news/unity-logo.png</url>
<link>http://www.unity3d.com/</link>
</image>
<item>
<title>Review of package &#x22;Good Drop&#x22; by Just Good Design</title>
<link>http://u3d.as/520</link>
<description>&#x3C;h1&#x3E;test&#x3C;/h1&#x3E;&#x3C;p&#x3E;test&#x3C;/p&#x3E;</description>
<guid isPermaLink="false">1145</guid>
<pubDate>Tue, 29 Oct 2013 23:01:55 -0000</pubDate>
</item>
<item>
<title>Reply to review of package &#x22;Good SVN&#x22; by Just Good Design</title>
<link>http://u3d.as/4ea</link>
<description>&#x3C;h1&#x3E;Reply from publisher&#x3C;/h1&#x3E;&#x3C;p&#x3E;testing&#x3C;/p&#x3E;</description>
<guid isPermaLink="false">1124</guid>
<pubDate>Tue, 29 Oct 2013 14:04:17 -0000</pubDate>
</item>
</channel>
</rss>
@willnode
Copy link

Now the link is gone. In short for what it's doing (in case someone doesn't have access to PHP):

https://publisher.assetstore.unity3d.com/feed/<publisher-name>/<api-key>/activity.rss

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment