Return to Snippet

Revision: 28061
at June 30, 2010 05:30 by screamwork


Initial Code
<?php
// build request format
$xml = simplexml_load_string('<?xml version="1.0" ?><methodCall />');
// method name
$xml->addChild('methodName','flickr.photos.search');
// parameters list
$params = $xml->addChild('params',null)->addChild('param',null)->addChild('value',null)->addChild('struct',null);
// add api key
$child = $params->addChild('member',null);
$child->addChild('name','api_key');
$child->addChild('value','**key-value**');
// add tag to search for
$child = $params->addChild('member',null);
$child->addChild('name','tags');
$child->addChild('value','ibuildings');
 
// make request
$url = 'http://api.flickr.com/services/xmlrpc/';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml->asXML());
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 
$response = curl_exec($ch);
$response_xml = simplexml_load_string($response);
curl_close($ch);

Initial URL

                                

Initial Description

                                

Initial Title
Flickr Search with curl

Initial Tags
curl, php

Initial Language
PHP