<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Accessing API via php script]]></title><description><![CDATA[<p dir="auto">Hi Joel, Phil,</p>
<p dir="auto">Been trying to get a listing of all of a given data point via the swagger API: /v1/point-values/{xid}/latest</p>
<p dir="auto">Given there are several hundred entries that I need a response for I am trying to script the process but keep running into the issue of "failed to open stream: HTTP request failed! HTTP/1.1 403 Access Denied" even though a copy &amp; paste of the string into a browser works perfectly.</p>
<p dir="auto">The script in question is very simple:</p>
<p dir="auto">&lt;?php<br />
$dpval = 2; //up to 321<br />
$dpnum = str_pad($dpval, 16, "0", STR_PAD_LEFT);<br />
$dpstring = "DP_HGU1_2_UII_$dpnum";<br />
$url = "http://&lt;ip.address&gt;:8080/rest/v1/point-values/$dpstring/latest?useRendered=true&amp;unitConversion=false&amp;limit=100&amp;useCache=true";</p>
<p dir="auto">while ($dpval &lt;= 321) {<br />
echo $dpstring;<br />
echo "&lt;br&gt;";<br />
echo file_get_contents($url);<br />
echo "&lt;br&gt;";<br />
echo "&lt;br&gt;";<br />
$dpval++;<br />
}<br />
?&gt;</p>
<p dir="auto">Have also tried numerous variations with various permutations with fopen and stream_context_create.</p>
<p dir="auto">Cheers,</p>
<p dir="auto">David</p>
]]></description><link>https://forum.mango-os.com/topic/2083/accessing-api-via-php-script</link><generator>RSS for Node</generator><lastBuildDate>Tue, 19 May 2026 13:43:36 GMT</lastBuildDate><atom:link href="https://forum.mango-os.com/topic/2083.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 25 Jan 2016 08:11:20 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Accessing API via php script on Mon, 22 Feb 2016 17:08:07 GMT]]></title><description><![CDATA[<p dir="auto"><a href="http://infiniteautomation.com/forum/topic/1944/mango-rest-api-special-key/2" rel="nofollow ugc">http://infiniteautomation.com/forum/topic/1944/mango-rest-api-special-key/2</a></p>
<p dir="auto">Has information on enabling CORS</p>
]]></description><link>https://forum.mango-os.com/post/11034</link><guid isPermaLink="true">https://forum.mango-os.com/post/11034</guid><dc:creator><![CDATA[phildunlap]]></dc:creator><pubDate>Mon, 22 Feb 2016 17:08:07 GMT</pubDate></item><item><title><![CDATA[Reply to Accessing API via php script on Sun, 21 Feb 2016 01:58:26 GMT]]></title><description><![CDATA[<p dir="auto">You can do it. Use GuzzleHttp, mess around with Swagger for a bit and be sure to take advantage of the Cookie feature.</p>
<p dir="auto">YOU NEED TO ENABLE CORS ON YOUR MANGO INSTALLATION OR IT WILL NEVER WORK.</p>
]]></description><link>https://forum.mango-os.com/post/11026</link><guid isPermaLink="true">https://forum.mango-os.com/post/11026</guid><dc:creator><![CDATA[thewizardguy]]></dc:creator><pubDate>Sun, 21 Feb 2016 01:58:26 GMT</pubDate></item><item><title><![CDATA[Reply to Accessing API via php script on Tue, 26 Jan 2016 13:27:37 GMT]]></title><description><![CDATA[<p dir="auto">Hi David,</p>
<p dir="auto">This is probably caused by the security token that is issued to your browser in a cookie at login. If you make a login via the API this XSRF token will be returned in the response to the successful login, with the header X-XSRF-TOKEN and should be included in all subsequent REST API requests.</p>
<p dir="auto">Swagger is only the page at <a href="http://mango" rel="nofollow ugc">http://mango</a>:port/swagger if swagger=true in env.properties. It's an automatically generated API explorer.</p>
]]></description><link>https://forum.mango-os.com/post/10890</link><guid isPermaLink="true">https://forum.mango-os.com/post/10890</guid><dc:creator><![CDATA[phildunlap]]></dc:creator><pubDate>Tue, 26 Jan 2016 13:27:37 GMT</pubDate></item></channel></rss>