Hi
I am getting the following output when trying to create a subscription:
Here is the example I am using:
<?php
require_once("OAuth.php");
$key = "{key}";
$secret = "{secret key}";
$hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
$protocol = "http";
$domain = "api.myspace.com";
$base = "/stream/subscription";
$base_url = "$protocol://$domain$base";
$action = 'POST';
$formParams = array("" => '{"Subscription" : { "Type" : "All", "Endpoint" : "http://maketrouble.net/myspacenew/test.php", "Rate" : 1, "Format" : "application/atom+xml", }} ');
$test_consumer = new OAuthConsumer($key, $secret, NULL);
$defaults = array("oauth_version" => OAuthRequest::$version,
"oauth_nonce" => md5(microtime() . mt_rand()),
"oauth_timestamp" => time(),
"oauth_consumer_key" => $test_consumer->key);
$formParams = array_merge($defaults, $formParams);
$req_req = new OAuthRequest($action, $base_url, $formParams);
$status = $req_req->sign_request($hmac_method, $test_consumer, NULL);
print_r($req_req);
$ch = curl_init($base_url);
$fp = fopen("streamSubscription.txt", "w");
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Length: ' . strlen($req_req->to_postdata())));
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $req_req->to_postdata());
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, TRUE);
curl_exec($ch);
curl_close($ch);
fclose($fp);
?>
But I got 409 error:
HTTP/1.1 409 Conflict
Content-Type: text/html
Server: Microsoft-IIS/7.5
X-Server: 10b9572a087c7f2a64b539f9df61e94a7c4e27f31b6ceffe
Date: Fri, 13 Aug 2010 06:02:49 GMT
Content-Length: 69
{"statusCode":"409","statusDescription":"Unexpected error occurred."}
What to do for creating a subscription?
Please help anybody.