Note that there are some explanatory texts on larger screens.

plurals
  1. POCalling Flickr API via Wordpress HTTP
    primarykey
    data
    text
    <p>I'm working on a wordpress plugin which call the flickr API via a clone of the phpFlickr class. The code below is customized to use the wordpress http wrapper functions to call flickr. I have printed the http POST parameters that i'm passing in but in each case the Flickr service is saying that the 'method is not supported'. Can anybody spot any issue which might be causing this? </p> <pre><code> function request ($command, $args = array(), $nocache = false) { if (substr($command,0,7) != "flickr.") { $command = "flickr." . $command; } //Process arguments, including method and login data. $args = array_merge(array("method" =&gt; $command, "format" =&gt; "php_serial", "api_key" =&gt; $this-&gt;api_key), $args); if (!empty($this-&gt;token)) { $args = array_merge($args, array("auth_token" =&gt; $this-&gt;token)); } elseif (!empty($_SESSION['phpFlickr_auth_token'])) { $args = array_merge($args, array("auth_token" =&gt; $_SESSION['phpFlickr_auth_token'])); } ksort($args); $auth_sig = ""; // http request arguments $body = array(); $headers = array(); if (!($this-&gt;response = $this-&gt;getCached($args)) || $nocache) { foreach ($args as $key =&gt; $data) { $auth_sig .= $key . $data; $body = array_merge(array($key =&gt; $data),$body); } if (!empty($this-&gt;secret)) { $api_sig = md5($this-&gt;secret . $auth_sig); $body = array_merge(array("api_sig" =&gt; $api_sig),$body); } $args = array_merge($args, $body); // set any headers $headers = array_merge(array( 'Connection' =&gt; 'Keep-Alive' ),$headers); $args = array_merge($args, $headers); error_log('http args '.print_r($args,true)); //Sends a request to Flickr's REST endpoint via POST. //$this-&gt;response = $this-&gt;wpRequest-&gt;request($this-&gt;REST,$args); $this-&gt;response = wp_remote_post($this-&gt;REST,$args); </code></pre> <p>The HTTP POST arguments</p> <pre><code> [15-Dec-2013 16:40:36 UTC] http args Array ( [api_key] =&gt; .........4e8ca6671ab35280c....... [format] =&gt; php_serial [method] =&gt; flickr.people.getPublicPhotos [page] =&gt; 10 [per_page] =&gt; 14 [user_id] =&gt; 34896940@N06 [api_sig] =&gt; 4de7adfc3aa7bc10167fee1741da5e84 [Connection] =&gt; Keep-Alive ) </code></pre> <p>The response is this</p> <pre><code> [15-Dec-2013 16:40:36 UTC] Array ( [headers] =&gt; Array ( [date] =&gt; Sun, 15 Dec 2013 16:40:36 GMT [p3p] =&gt; policyref="http://info.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE LOC GOV" [content-length] =&gt; 128 [cache-control] =&gt; private [x-served-by] =&gt; www44.flickr.bf1.yahoo.com [vary] =&gt; Accept-Encoding [content-type] =&gt; text/xml; charset=utf-8 [age] =&gt; 0 [server] =&gt; ATS/4.0.2 [via] =&gt; http/1.1 r02.ycpi.ams.yahoo.net (ApacheTrafficServer/4.0.2 [c sSf ]) ) [body] =&gt; &lt;xml version="1.0" encoding="utf-8" ?&gt; &lt;rsp stat="fail"&gt; &lt;err code="112" msg="Method &amp;quot;unknown&amp;quot; not found" /&gt; &lt;/rsp&gt; [response] =&gt; Array ( [code] =&gt; 200 [message] =&gt; OK ) [cookies] =&gt; Array ( ) [filename] =&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload