I'm trying to change the twitpic information with my image hosting service. The response from my api is not JSON but XML I quess this is the problem? Can somebody help me out? function twitter_twitrp_page($query) { if (user_type() == 'oauth') { //V2 of the Twitpic API allows for OAuth //http://dev.twitpic.com/docs/2/upload/ //Has the user submitted an image and message? if ($_POST['message']) { $twitrpURL = 'http://twitrp.com/drippic2/upload'; //Set the initial headers $header = array( 'X-Auth-Service-Provider: https://api.twitter.com/1/account/verify_credentials.json', 'X-Verify-Credentials-Authorization: OAuth realm="http://api.twitter.com/"' ); //Using Abraham's OAuth library require_once('OAuth.php'); // instantiating OAuth customer $consumer = new OAuthConsumer(OAUTH_CONSUMER_KEY, OAUTH_CONSUMER_SECRET); // instantiating signer $sha1_method = new OAuthSignatureMethod_HMAC_SHA1(); // user's token list($oauth_token, $oauth_token_secret) = explode('|', $GLOBALS['user']['password']); $token = new OAuthConsumer($oauth_token, $oauth_token_secret); // Generate all the OAuth parameters needed $signingURL = 'https://api.twitter.com/1/account/verify_credentials.json'; $request = OAuthRequest::from_consumer_and_token($consumer, $token, 'GET', $signingURL, array()); $request->sign_request($sha1_method, $consumer, $token); $header[1] .= ", oauth_consumer_key="" . $request->get_parameter('oauth_consumer_key') ."""; $header[1] .= ", oauth_signature_method="" . $request->get_parameter('oauth_signature_method') ."""; $header[1] .= ", oauth_token="" . $request->get_parameter('oauth_token') ."""; $header[1] .= ", oauth_timestamp="" . $request->get_parameter('oauth_timestamp') ."""; $header[1] .= ", oauth_nonce="" . $request->get_parameter('oauth_nonce') ."""; $header[1] .= ", oauth_version="" . $request->get_parameter('oauth_version') ."""; $header[1] .= ", oauth_signature="" . urlencode($request->get_parameter('oauth_signature')) ."""; //open connection $ch = curl_init(); //Set paramaters curl_setopt($ch, CURLOPT_HTTPHEADER, $header); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); //set the url, number of POST vars, POST data curl_setopt($ch,CURLOPT_URL,$twitrpURL); //TwitPic requires the data to be sent as POST $media_data = array( 'media' => '@'.$_FILES['media']['tmp_name'], 'message' => ' ' . stripslashes($_POST['message']), //A space is needed because twitpic b0rks if first char is an @ //'key'=>TWITPIC_API_KEY ); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch,CURLOPT_POSTFIELDS,$media_data); //execute post $result = curl_exec($ch); $response_info=curl_getinfo($ch); //close connection curl_close($ch); if ($response_info['http_code'] == 200) { //Success //Decode the response $xml = json_decode($result); $id = $xml->id; $twitrpURL = $xml->url; $text = $xml->text; $message = trim($text) . " " . $twitrpURL; //Send the user's message to twitter $request = API_URL.'statuses/update.json'; $post_data = array('source' => 'dabr', 'status' => $message); $status = twitter_process($request, $post_data); //Back to the timeline twitter_refresh("twitrp/confirm/$id"); } else { $content = "Twitrp upload failed. No idea why!"; $content .= ""; $xml = json_decode($result); $content .= "message " . urlencode($_POST['message']); $content .= "xml " . print_r($xml); $content .= "Response " . print_r($response_info); $content .= "header " . print_r($header); $content .= "media_data " . print_r($media_data); $content .= "URL was " . $twitrpURL; $content .= "File uploaded was " . $_FILES['media']['tmp_name']; $content .= ""; } } elseif ($query[1] == 'confirm') { $content = "Upload success. Image posted to Twitter."; } else { $content = "Image Message (optional):110"; $content .= js_counter("message", "110"); } return theme('page', 'Twitrp Upload', $content); } }