hi, am working with twitter and using the following code to create a follow request $postarg=false; $url="http://twitter.com/friendships/create/xxx.xml?follow=true"; // Initialize CURL $ch = curl_init($url); // Tell CURL we are doing a POST // Set the username and password in the CURL call curl_setopt($ch, CURLOPT_USERPWD, 'xxxx:yyyy'); // Set some cur flags (not too important) curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_NOBODY, 0); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_POST, true); // Give CURL the arguments in the POST curl_setopt ($ch, CURLOPT_POSTFIELDS, $postarg); // execute the CURL call $response = curl_exec($ch); echo $response; // Get information about the response $responseInfo=curl_getinfo($ch); // Close the CURL connection curl_close($ch); // Make sure we received a response from Twitter if(intval($responseInfo['http_code'])==200){ // Display the response from Twitter echo $response; }else{ // Something went wrong echo "Error: " . $responseInfo['http_code']; } ?> PHP: no matter what i do it is not creating a follow ...altough its returing the details of the user to which the follow request was targeted..i code the from some twitter lib and looks pretty good to me as well.. any help will be highly appreciated.. thanks
Just tried this out and it works fine. <?php $url = "http://twitter.com/friendships/create/PERSON.xml?follow=yes"; $ch = curl_init(); $user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; ". "Windows NT 5.0)"; $ch = curl_init(); curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); curl_setopt( $ch, CURLOPT_POST, true ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt( $ch, CURLOPT_FOLLOWLOCATION , 1 ); curl_setopt( $ch, CURLOPT_URL, $url ); curl_setopt($ch, CURLOPT_USERPWD, 'BLAH'); curl_setopt( $ch, CURLOPT_REFERER, $ref ); curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); curl_setopt ($ch, CURLOPT_POSTFIELDS, false); $return = curl_exec($ch); curl_close($ch); $xml = simplexml_load_string($return); var_dump($xml); ?> PHP:
thanks for the reply..i figured out the fault.. now just needs to get my ip whitelisted..and they aint replying to my requests!!