<?xml version="1.0" encoding="utf-8" ?><?xml-stylesheet type="text/xsl" href="http://www.daniweb.com/js/rss.xsl"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>DaniWeb IT Discussion Community
			 - PHP			Code Snippets					</title>
		<link>http://www.daniweb.com/web-development/php/code/_/17</link>
		<description>Our PHP forum is the place for Q&amp;A-style discussions related to this popular development language.  LAMP programmers will appreciate our separate Apache forum, within the Networking sub-category of the Hardware and Software category, and MySQL forum, also within the Web Development category.</description>
		<language>en-US</language>
		<ttl>60</ttl>
		<!-- PubSubHubbub Discovery -->
		<link rel="hub" href="http://daniweb.superfeedr.com/" xmlns="http://www.w3.org/2005/Atom" />
		<link rel="self" href="http://www.daniweb.com/rss/pull/17/code" xmlns="http://www.w3.org/2005/Atom" />
		<!-- End Of PubSubHubbub Discovery -->
				<item>
			<title>RSS Dashboard</title>
			<link>http://www.daniweb.com/web-development/php/code/452374/rss-dashboard</link>
			<pubDate>Sat, 13 Apr 2013 14:42:21 +0000</pubDate>
			<description>Attached is the code for my RSS dashboard, using the DaniWeb API. It's an improved version of the mashup I posted earlier, using jQuery to get all feeds asynchronously. The part which initially loads the forums is shown below. It creates an API object, and a Parser object. The first ...</description>
			<content:encoded><![CDATA[ <p>Attached is the code for my RSS dashboard, using the DaniWeb API. It's an improved version of the mashup I posted earlier, using jQuery to get all feeds asynchronously. The part which initially loads the forums is shown below.</p>

<p>It creates an API object, and a Parser object. The first gets the forums list in JSON format, the second the extracts all forums to create the initial empty div's. A static method to a decorator function is passed, which adds the actual markup. The Parser and Decorator classes are in the zip file, so I won't discuss those here.</p>

<p>If you want to see the result, go <a href="http://dwapi.pritaeas.net/DwRssDashboard/" rel="nofollow">here</a>.</p>

<p>Any question, remarks, etc. are welcome.</p>

<p>For some reason I'm not seeing my attached file, you can <a href="http://dwapi.pritaeas.net/DwRssDashboard/DwRssDashboard.zip" rel="nofollow">download the zip file</a>.</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/php/17">PHP</category>
			<dc:creator>pritaeas</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/php/code/452374/rss-dashboard</guid>
		</item>
				<item>
			<title>PHP class for DaniWeb API&#039;s unauthenticated calls.</title>
			<link>http://www.daniweb.com/web-development/php/code/451816/php-class-for-daniweb-apis-unauthenticated-calls</link>
			<pubDate>Sat, 06 Apr 2013 10:00:03 +0000</pubDate>
			<description>Here's my base class and class for the unauthenticated DaniWeb API calls. Not every method has all features implemented yet, and it's not been fully tested either. Here's how to start using it: include 'DwApiBase.class.php'; include 'DwApiOpen.class.php'; $dwapi = new DwApiOpen(); $result = $dwapi-&gt;GetMemberActivityPoints(94719); $result = $dwapi-&gt;GetMemberEndorsements(94719); $result = $dwapi-&gt;GetMemberReputationComments(94719); ...</description>
			<content:encoded><![CDATA[ <p>Here's my base class and class for the unauthenticated DaniWeb API calls. Not every method has all features implemented yet, and it's not been fully tested either. Here's how to start using it:</p>

<pre><code>include 'DwApiBase.class.php';
include 'DwApiOpen.class.php';

$dwapi = new DwApiOpen();

$result = $dwapi-&gt;GetMemberActivityPoints(94719);
$result = $dwapi-&gt;GetMemberEndorsements(94719);
$result = $dwapi-&gt;GetMemberReputationComments(94719);
$result = $dwapi-&gt;SearchArticles('daniweb-api');
$result = $dwapi-&gt;SearchMembers('pritaeas');
</code></pre>

<p>Open to suggestions, questions, etc.</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/php/17">PHP</category>
			<dc:creator>pritaeas</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/php/code/451816/php-class-for-daniweb-apis-unauthenticated-calls</guid>
		</item>
				<item>
			<title>All-in-one Daniweb API Class</title>
			<link>http://www.daniweb.com/web-development/php/code/451674/all-in-one-daniweb-api-class</link>
			<pubDate>Thu, 04 Apr 2013 13:09:42 +0000</pubDate>
			<description>OK, as promised, here's an updated 'quick(!) and dirty' class for retrieving and setting data via the Daniweb API. It allows the extraction of data based around: # DATA RETRIEVAL &amp; SETTING # ## non-OAuth ## * forums * articles * posts * members * activity points * endorsements * ...</description>
			<content:encoded><![CDATA[ <p>OK, as promised, here's an updated 'quick(!) and dirty' class for retrieving and setting data via the Daniweb API. It allows the extraction of data based around:</p>

<h1>DATA RETRIEVAL &amp; SETTING</h1>

<h2>non-OAuth</h2>

<ul><li>forums</li>
<li>articles</li>
<li>posts</li>
<li>members</li>
<li>activity points</li>
<li>endorsements</li>
<li>reputation</li>
</ul>

<h2>OAuth (requires client_id and secret key)</h2>

<ul><li>who am i? (<strong>me</strong> - more data than from non-OAuth members)</li>
<li>articles (expansion of non-OAuth articles)</li>
<li>watched articles (watch and unwatch)</li>
<li>voting on posts (upvote and downvote)</li>
<li>PMs <strong>(currently inactive)</strong></li>
</ul>

<h2>Direct URL retrieval</h2>

<ul><li>getLink</li>
</ul>

<h2>RSS</h2>

<ul><li>get data for RSS</li>
</ul>

<p>This is in no way 'production'-standard code. It is intended for picking apart in order to build your own solutions, e.g. if you intend on using the API or entering the API contest. NB - there is very poor error checking / no exception handling.</p>

<p><strong>Also check out pritaeas' class(es).</strong></p>

<h1>USAGE</h1>

<h2>non-OAuth</h2>

<pre><code>require 'dwapi.class.php';
$dw = new dwAPI;

echo $dw-&gt;getForums(); //echo json output of all forums
echo $dw-&gt;getForums(false,17) //echo data about the PHP (#17) forum
echo $dw-&gt;getList('<a href="http://www.daniweb.com/api/members/1/posts?filter=solved" rel="nofollow">http://www.daniweb.com/api/members/1/posts?filter=solved</a>'); // get direct url data. NO CHECKS!
</code></pre>

<h2>OAuth</h2>

<pre><code>//set $client_id and $client_secret
require 'dwapi.class.php';
$dw = new dwAPI($client_id, $client_secret);
echo $dw-&gt;getMe(); //get my data
</code></pre>

<h2>RSS</h2>

<pre><code>require 'dwapi.class.php';
$dw = new dwAPI;

echo $dw-&gt;formatFeed($dw-&gt;getRSS(17),5); //echo first 5 links from PHP (#17) 
</code></pre>

<p>Hope it helps. Oh, and as always, please feel free to point out errors, improvements and any daft implementations. <strong>diafol :)</strong></p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/php/17">PHP</category>
			<dc:creator>diafol</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/php/code/451674/all-in-one-daniweb-api-class</guid>
		</item>
				<item>
			<title>DaniWeb API mashup</title>
			<link>http://www.daniweb.com/web-development/php/code/451489/daniweb-api-mashup</link>
			<pubDate>Tue, 02 Apr 2013 09:20:08 +0000</pubDate>
			<description>## API Mashup ## This example is a mashup of [diafol's class](http://www.daniweb.com/web-development/php/code/451428/daniweb-api-class-for-getting-forums), [Dani's parsing code](http://www.daniweb.com/api/documentation) and [my class](http://www.daniweb.com/web-development/php/code/451390/daniweb-api-rss-class). It uses diafol's dwAPI class to retrieve a list of all forums, loops through them, and uses my Rss class to get the respective RSS feeds. It will show each forum in ...</description>
			<content:encoded><![CDATA[ <h2>API Mashup</h2>

<p>This example is a mashup of <a href="http://www.daniweb.com/web-development/php/code/451428/daniweb-api-class-for-getting-forums" rel="nofollow">diafol's class</a>, <a href="http://www.daniweb.com/api/documentation" rel="nofollow">Dani's parsing code</a> and <a href="http://www.daniweb.com/web-development/php/code/451390/daniweb-api-rss-class" rel="nofollow">my class</a>.</p>

<p>It uses diafol's dwAPI class to retrieve a list of all forums, loops through them, and uses my Rss class to get the respective RSS feeds. It will show each forum in a separate div (with Dani's code) with it's title and no more than the five latest posts. The div will be omitted if there are no posts. (@Dani: some feeds give a parse error, and that's shown instead.)</p>

<p>You can try it yourself. Note that looping through all the forums takes some time, that's why the <code>set_time_limit(0)</code> was included. If you want to see the result, look <a href="http://dwapi.pritaeas.net/Tests/mashup.php" rel="nofollow">here</a>.</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/php/17">PHP</category>
			<dc:creator>pritaeas</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/php/code/451489/daniweb-api-mashup</guid>
		</item>
				<item>
			<title>Facebook News Feed Api</title>
			<link>http://www.daniweb.com/web-development/php/code/451463/facebook-news-feed-api</link>
			<pubDate>Tue, 02 Apr 2013 05:53:19 +0000</pubDate>
			<description>Hello Community, I have been looking for a facebook news feed api, i couldn't find one. All i could find is bits of script for construct my own news feed api. So thats what i did and i thought i might share the script with you it's a bit messy ...</description>
			<content:encoded><![CDATA[ <p>Hello Community,<br />
I have been looking for a facebook news feed api, i couldn't find one. All i could find is bits of script for construct my own news feed api.</p>

<p>So thats what i did and i thought i might share the script with you it's a bit messy but it works.</p>

<p>Here is how t use it:<br />
1. Goto <a href="https://www.facebook.com/developers" rel="nofollow">https://www.facebook.com/developers</a> and login.<br />
2. Click "Create New App". <img src="/attachments/fetch/L2ltYWdlcy9hdHRhY2htZW50cy8zLzZlY2JiYTgyNDdiMThjY2E1MGU0NjdmOGNlMDA2M2IxLnBuZw%3D%3D/203" alt="6ecbba8247b18cca50e467f8ce0063b1" /><br />
3. Enter an app name i've used "NewsFeed" make sure it's valid then leave app namespace blank and web hosting un-ticked then click "Continue". <img src="/attachments/fetch/L2ltYWdlcy9hdHRhY2htZW50cy8zLzZjZjg1M2VlYjE1YmZjNDJmNjk1MzY1OWQ2YTQzNjc2LnBuZw%3D%3D/500" alt="6cf853eeb15bfc42f6953659d6a43676" title="6cf853eeb15bfc42f6953659d6a43676" /><br />
4. Then copy and paste the script:</p>

<p>Then to get your access token goto <a href="https://graph.facebook.com/oauth/access_token?grant_type=client_credentials&amp;client_id=PUT_APP_ID_HERE&amp;client_secret=PUT_APP_SECRET_HERE" rel="nofollow">https://graph.facebook.com/oauth/access_token?grant_type=client_credentials&amp;client_id=PUT_APP_ID_HERE&amp;client_secret=PUT_APP_SECRET_HERE</a></p>

<p>I hope you found this tutorial easy to follow, but if you have any question just leave a comment below and i will get back to you.</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/php/17">PHP</category>
			<dc:creator>joshl_1995</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/php/code/451463/facebook-news-feed-api</guid>
		</item>
				<item>
			<title>Daniweb API Class for Getting Forums</title>
			<link>http://www.daniweb.com/web-development/php/code/451428/daniweb-api-class-for-getting-forums</link>
			<pubDate>Mon, 01 Apr 2013 19:43:06 +0000</pubDate>
			<description># As of 4/4/2013 # This class has now been updated and posted here: http://www.daniweb.com/web-development/php/code/451674/all-in-one-daniweb-api-class# # ORIGINAL POST # This code can be used to retrieve a forum list with various options with regard to display. This class could be extended for articles, posts, etc etc. The retrieval methods include ...</description>
			<content:encoded><![CDATA[ <h1>As of 4/4/2013</h1>

<p>This class has now been updated and posted here: <a href="http://www.daniweb.com/web-development/php/code/451674/all-in-one-daniweb-api-class#" rel="nofollow">http://www.daniweb.com/web-development/php/code/451674/all-in-one-daniweb-api-class#</a></p>

<h1>ORIGINAL POST</h1>

<p>This code can be used to retrieve a forum list with various options with regard to display. This class could be extended for articles, posts, etc etc.</p>

<p>The retrieval methods include <code>file_get_contents()</code> and <code>cURL</code>. The constructor allows manually setting the method or allowing php to determine whether a retrieval method is available.</p>

<p>The call to retrieve data is pretty simple, for example:</p>

<pre><code>//CLIENT CODE
require 'dwapi.class.php';  
$dw = new dwAPI;
echo $dw-&gt;getForums();
</code></pre>

<p>Alternatively if you needed more specific output, the getForums() method takes 3 optional params:</p>

<p>1) (bool) 'include self' default = false<br />
2) (mixed) 'forum list' default = false [can be: array e.g. array(1,3,4); string e.g. '1,3,4'; int e.g. 4]<br />
3) (string) 'relatives' default = false [can be 'children'|'descendants'|'ancestors']</p>

<p>e.g.1</p>

<pre><code>require 'dwapi.class.php';  
$dw = new dwAPI;
echo $dw-&gt;getForums(false,'1,3,4'); //get details for forums 1,3 and 4
</code></pre>

<p>e.g.2</p>

<pre><code>require 'dwapi.class.php';  
$dw = new dwAPI;
echo $dw-&gt;getForums(true, array(1,2), 'descendants');
</code></pre>

<p>The output will be in json format, but you could to the following to get php assoc array:</p>

<pre><code>require 'dwapi.class.php';  
$dw = new dwAPI;
$arr = $dw-&gt;json2Array($dw-&gt;getForums(true, array(1,2), 'descendants'));

echo "&lt;pre&gt;";print_r($arr);echo "&lt;/pre&gt;";
</code></pre>

<p>Anyhow, I'm sure seasoned OOPers will find plenty to complain about. If so, please send in your improvements.</p>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/php/17">PHP</category>
			<dc:creator>diafol</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/php/code/451428/daniweb-api-class-for-getting-forums</guid>
		</item>
				<item>
			<title>DaniWeb API RSS class</title>
			<link>http://www.daniweb.com/web-development/php/code/451390/daniweb-api-rss-class</link>
			<pubDate>Mon, 01 Apr 2013 11:57:53 +0000</pubDate>
			<description>## RSS Class ## The code snippet is a PHP class for retrieving RSS feeds from the DaniWeb website. There are two exposed methods, one for retrieving the list of predefined article types, and another to get a specific RSS feed. If you pass parameters to this method, there is ...</description>
			<content:encoded><![CDATA[ <h2>RSS Class</h2>

<p>The code snippet is a PHP class for retrieving RSS feeds from the DaniWeb website. There are two exposed methods, one for retrieving the list of predefined article types, and another to get a specific RSS feed. If you pass parameters to this method, there is a basic check to see if the forum ID is an integer and greater than zero. The article type will be checked against the predefined list.</p>

<h2>To do</h2>

<p>I want to combine this class later with the DaniWeb API, so it can retrieve a valid list of forum ID's to choose from. For now, I'll leave that as an exercise for you to add.</p>

<p>Another addition can be to add the XML parsing into the class, so it can return the result in an associative array.</p>

<h2>Usage example</h2>

<pre><code>include 'Rss.class.php';

$rss = new Rss();

// Get the list of predefined article types.
$articleTypes = $rss-&gt;GetArticleTypes();

// Get the RSS feed for unanswered Hardware and Software quetions.
$feed = $rss-&gt;GetFeed(1, 'unanswered');

if ($feed)
{
    // Taken from the API documentation.
    $articles = new SimpleXMLElement($feed);
    foreach ($articles-&gt;channel-&gt;item as $article)
    {
        echo '&lt;a href="' . $article-&gt;link . '"&gt;' . $article-&gt;title . '&lt;/a&gt;&lt;br /&gt;';
    }
}
</code></pre>
 ]]></content:encoded>
			<category domain="http://www.daniweb.com/web-development/php/17">PHP</category>
			<dc:creator>pritaeas</dc:creator>
			<guid isPermaLink="true">http://www.daniweb.com/web-development/php/code/451390/daniweb-api-rss-class</guid>
		</item>
			</channel>
</rss>