Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96231886
override.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Dec 24, 00:29
Size
1 KB
Mime Type
text/x-php
Expires
Thu, Dec 26, 00:29 (2 d)
Engine
blob
Format
Raw Data
Handle
23146425
Attached To
rPH Phabricator
override.php
View Options
<?php
require
(
__DIR__
.
'/../bootstrap.php'
);
// We can override the default parser configuration options be registering
// a parser with different configuration options for a particular mime type
// Example setting a namespace for the XMLHandler parser
$conf
=
array
(
'namespace'
=>
'http://example.com'
);
\Httpful\Httpful
::
register
(
\Httpful\Mime
::
XML
,
new
\Httpful\Handlers\XmlHandler
(
$conf
));
// We can also add the parsers with our own...
class
SimpleCsvHandler
extends
\Httpful\Handlers\MimeHandlerAdapter
{
/**
* Takes a response body, and turns it into
* a two dimensional array.
*
* @param string $body
* @return mixed
*/
public
function
parse
(
$body
)
{
return
str_getcsv
(
$body
);
}
/**
* Takes a two dimensional array and turns it
* into a serialized string to include as the
* body of a request
*
* @param mixed $payload
* @return string
*/
public
function
serialize
(
$payload
)
{
$serialized
=
''
;
foreach
(
$payload
as
$line
)
{
$serialized
.=
'"'
.
implode
(
'","'
,
$line
)
.
'"'
.
"
\n
"
;
}
return
$serialized
;
}
}
\Httpful\Httpful
::
register
(
'text/csv'
,
new
SimpleCsvHandler
());
Event Timeline
Log In to Comment