Skip to content

Instantly share code, notes, and snippets.

@sagotsky
Created July 1, 2013 14:07
Show Gist options
  • Save sagotsky/5901066 to your computer and use it in GitHub Desktop.
Save sagotsky/5901066 to your computer and use it in GitHub Desktop.
Updates a topic on getsaitsfaction.
<?php
/*
* Attempting to update a getsatisfaction topic from the api.
*/
set_include_path('/opt/pear');
require_once('HTTP/Request2.php');
$url = 'https://api.getsatisfaction.com/topics/api_topic_test'; //slug works here. haven't tested id.
$topic = array(
'topic' => array(
'subject' => 'API -> Topic test',
'style' => 'idea',
'status' => 'pending',
'additional_detail' => 'additional detail updated by put',
),
);
$username = 'AzureDiamond';
$password = 'hunter2';
#$request = new HTTP_Request2($url, HTTP_Request2::METHOD_POST);
$request = new HTTP_Request2($url, HTTP_Request2::METHOD_PUT);
$request->setAuth($username, $password, HTTP_Request2::AUTH_BASIC);
$request->setHeader('Content-type: application/json');
$request->setBody(json_encode($topic));
$request->setConfig(array('ssl_verify_peer'=>FALSE, 'ssl_verify_host'=>FALSE));
$response = $request->send();
$body = $response->getBody();
echo $body;
?>
@rtanglao
Copy link

nice php code! i have ruby code for this at: https://github.com/rtanglao/momogs/blob/master/postReply.rb if anybody is looking for ruby

@rtanglao
Copy link

hmmm i take that back :-) my bad!
my ruby code posts replies using HTTP POST , it doesn't modify using HTTP PUT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment