29, May 2012

rss to twitter error - webmaster forum

 
Webdigity webmaster forums
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: rss to twitter error
« previous next »
Pages: [1] 2 Print
Instabuck - The easy way to sell digital products online

Author Topic: rss to twitter error  (Read 3027 times)
Nikolas' Servant's Servant
*
Posts: 29
190 credits
Members referred : 0


« on: Jul 18, 2009, 09:23:04 pm »

I am getting this error
Problem with the url shortening service. Check back later. Error: Expected 3 GET parameters: user, pass, url

Any help appreciated...
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #1 on: Jul 18, 2009, 10:31:03 pm »

Probably you are not settings the $settings array at the beginning. Have you done any changes to the code of the script?

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Nikolas' Servant's Servant
*
Posts: 29
190 credits
Members referred : 0


« Reply #2 on: Jul 18, 2009, 11:00:25 pm »

The settings is set... no changes... though I have tried 'hard coding' my username and password into the URL api ... that didn't work,.

Here's the code
Code:
<?php
/*
 * Script that posts multiple RSS feeds to twitter
 * 
 * Use this with crontab (it works with CLI too)
 * to post your feed's content to twitter
 * 
 * A tutorial by:
 * http://www.webdigity.com/
 * 
 */

$settings ['twitter-username'] = 'xxxxx';// Your twitter username
$settings ['twitter-password'] = 'xxxxx';// Your twitter password
$settings ['feed-url'] ='xxxxxxl';//The url of the feed we are going to post to twitter

set_time_limit(0);//We need this because otherwise php will probably time out
//Let's see if we have the curl library
if (!extension_loaded('curl') && !dl('curl.' . (stristr(php_OS'WIN')?'dll':'so'))) die( 'Curl is not loaded' );
//Now we need a file to log the last entry so we wont post it again
$file dirname(__FILE__) . '/feed.log.txt';
if ( !
file_exists$file ) ){
$fp = @fopen$file'w');
if (! $fp )
die( 'Could not write to log file. Check your permissions.' );
fclose$fp );
} else
if ( !is_writable$file ) ) die( 'Could not write to log file. Check your permissions.' );
//Fetch the RSS feed
$ch curl_init$settings['feed-url'] );
curl_setopt($chCURLOPT_TIMEOUT10);
curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
$feed simplexml_load_string curl_exec($ch) );
curl_close($ch);
//Parse the feed
$messages = array();//Here we will store all the messages that we are going to post to twitter
foreach( $feed->channel->item as $item ){
$title $item->title// If you want to fetch the description instead use $item->description
$url $item->link;
//Have we already posted that?
if ( $url == file_get_contents($file) ) break;
//Now do the actual posting.

//First we need to shorten the url

$ch curl_init'http://twt.gs/?url='.$url.'&user='.$settings['twitter-username'].'&pass='.$settings['twitter-password'] );
curl_setopt($chCURLOPT_TIMEOUT10);
curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
$shortURL curl_exec($ch);
$resp curl_getinfo($chCURLINFO_HTTP_CODE);
curl_close($ch);
if ( $resp != '200' )
die('Problem with the url shortening service. Check back later. Error: '.$shortURL);


//Now Calculate the twit message
$cnt 140 strlen($shortURL) - 1;
$messages [] = strlen($title) <= $cnt $title ' ' $shortURL substr($title,0,$cnt-3).'... '.$shortURL;
$lastURL = empty($lastURL) ? $url $lastURL;
}
//Post to twitter
while( $message array_pop($messages) ){
$ch curl_init('http://twitter.com/statuses/update.xml');
curl_setopt($chCURLOPT_CONNECTTIMEOUT10);
curl_setopt($chCURLOPT_RETURNTRANSFER1);
curl_setopt($chCURLOPT_POST1);
curl_setopt($chCURLOPT_POSTFIELDS'status='.urlencode($message));
curl_setopt($chCURLOPT_USERPWD$settings['twitter-username'].':'.$settings['twitter-password']);

$response curl_exec($ch);
$resp curl_getinfo($chCURLINFO_HTTP_CODE);
curl_close($ch);
if ( $resp != '200' )
die('Problem with twitter. We should try later. Twitter reported: '.$response);
else
sleep(5);//Sleep 5 seconds before the next update
}
$fp fopen($file'w');
fwrite($fp$lastURL);
fclose($fp);
?>

Nikolas' Servant's Servant
*
Posts: 29
190 credits
Members referred : 0


« Reply #3 on: Jul 18, 2009, 11:02:18 pm »

I also noticed that if I remove this section the code will actually execute... well sort off... it will post the entire feed to twitter, but with no URLs.  It also does not use the log properly, in that if I run the script again it will repost the entire feed.  Thanks for your help.

Code:
//First we need to shorten the url

$ch = curl_init( 'http://twt.gs/?url='.$url.'&user='.$settings['twitter-username'].'&pass='.$settings['twitter-password'] );
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$shortURL = curl_exec($ch);
$resp = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ( $resp != '200' )
die('Problem with the url shortening service. Check back later. Error: '.$shortURL);
Nikolas' Servant's Servant
*
Posts: 29
190 credits
Members referred : 0


« Reply #4 on: Jul 22, 2009, 01:23:35 am »

help pls?
Nikolas' Servant's Servant
*
Posts: 29
190 credits
Members referred : 0


« Reply #5 on: Jul 24, 2009, 02:14:31 pm »

anyone?
Nikolas' Servant's Servant
*
Posts: 29
190 credits
Members referred : 0


« Reply #6 on: Jul 29, 2009, 02:20:50 pm »

can anyone help?
Total Zero
*
Posts: 5
34 credits
Members referred : 0


« Reply #7 on: Jul 29, 2009, 05:17:10 pm »

Ugh - I'm reading through the code - not really noticing anything out of the ordinary - Did you change anything??
Nikolas' Servant's Servant
*
Posts: 29
190 credits
Members referred : 0


« Reply #8 on: Jul 31, 2009, 04:01:58 pm »

Nope... nothing changed other than username etc... is anyone using this code successfully?  Maybe twitter changed something?
Total Zero
*
Posts: 5
34 credits
Members referred : 0


« Reply #9 on: Jul 31, 2009, 04:12:37 pm »

/statuses/update.xml' Statuses? Typo maybe? That's what I would back over - ensure that all of your spelling is correct for linkage - usually that's what I make mistakes on. Don't pull your hair out over it - it's most likely something very simple you've overlooked Smiley
Nikolas' Servant's Servant
*
Posts: 29
190 credits
Members referred : 0


« Reply #10 on: Aug 04, 2009, 11:29:11 pm »

Thanks insight... "http://twitter.com/statuses/update.xml" is in the original code.. .I didn't touch that.. ?
Nikolas' Servant's Servant
*
Posts: 29
190 credits
Members referred : 0


« Reply #11 on: Aug 04, 2009, 11:32:03 pm »

incidentally it's not writing anything to feed.log..txt either...
Nikolas' Servant's Servant
*
Posts: 29
190 credits
Members referred : 0


« Reply #12 on: Aug 09, 2009, 08:49:02 pm »

help?
Nikolas' Servant's Servant
*
Posts: 29
190 credits
Members referred : 0


« Reply #13 on: Sep 04, 2009, 01:46:24 am »

still looking for help
Nikolas' Servant's Servant
*
Posts: 29
190 credits
Members referred : 0


« Reply #14 on: Sep 12, 2009, 02:16:15 pm »

bump
Chicken-run Manager
*
Posts: 9
54 credits
Members referred : 0


« Reply #15 on: Sep 13, 2009, 05:50:28 am »

Just use a different url shortening service. Replace the other one with this code and try.

Code:
$ch = curl_init( 'http://tinyurl.com/api-create.php?url=' .$url );

Should work then.
Nikolas' Servant's Servant
*
Posts: 29
190 credits
Members referred : 0


« Reply #16 on: Sep 18, 2009, 05:18:36 am »

progress being made... still not writing to log file..... links not posting to twit the word "Error" instead.. but at least it is tweeting...

URL Shortening now looks like:
Code:

//First we need to shorten the url
$ch = curl_init( 'http://tinyurl.com/api-create.php?url='.$url.'&user='.$settings['twitter-username'].'&pass='.$settings['twitter-password']);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$shortURL = curl_exec($ch);
$resp = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ( $resp != '200' )
die('Problem with the url shortening service. Check back later. Error: '.$shortURL);


Chicken-run Manager
*
Posts: 9
54 credits
Members referred : 0


« Reply #17 on: Sep 18, 2009, 08:16:20 am »

you can't use the line

$ch = curl_init( 'http://tinyurl.com/api-create.php?url='.$url.'&user='.$settings['twitter-username'].'&pass='.$settings['twitter-password']);

It has to be replaced with the one I gave you otherwise tinyurl will put your username and password at the end of all your urls.. lol.. Tinyurl does not need your username and password like the other url shortening company did.

Replace that line with:
Code:
$ch = curl_init( 'http://tinyurl.com/api-create.php?url=' .$url );

Also create a blank feed.log.txt and upload to same folder that you have the rss to twitter script and chmod on log file to 777. It should work then.
« Last Edit: Sep 18, 2009, 08:20:29 am by raymond4000 »
Nikolas' Servant's Servant
*
Posts: 29
190 credits
Members referred : 0


« Reply #18 on: Sep 18, 2009, 08:31:37 pm »

raymond - I appreciate you willing to work with me on this so much!
We have made good progress  so far... it's posting to twitter, and loading the the last url into the feed.log.txt file... however ON twitter, there is no link, it still says "ERROR" in place of a link.  My code is below, thank you for your help.

Code:
//First we need to shorten the url
$ch = curl_init( 'http://tinyurl.com/api-create.php?url='.$url );
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$shortURL = curl_exec($ch);
$resp = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ( $resp != '200' )
die('Problem with the url shortening service. Check back later. Error: '.$shortURL);


//Now Calculate the twit message
$cnt = 140 - strlen($shortURL) - 1;
$messages [] = strlen($title) <= $cnt ? $title . ' ' . $shortURL : substr($title,0,$cnt-3).'... '.$shortURL;
$lastURL = empty($lastURL) ? $url : $lastURL;
}
//Post to twitter
while( $message = array_pop($messages) ){
$ch = curl_init('http://twitter.com/statuses/update.xml');
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'status='.urlencode($message));
curl_setopt($ch, CURLOPT_USERPWD, $settings['twitter-username'].':'.$settings['twitter-password']);

$response = curl_exec($ch);
$resp = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ( $resp != '200' )
die('Problem with twitter. We should try later. Twitter reported: '.$response);
else
sleep(5);//Sleep 5 seconds before the next update
}
$fp = fopen($file, 'w');
fwrite($fp, $lastURL);
fclose($fp);
?>

Chicken-run Manager
*
Posts: 9
54 credits
Members referred : 0


« Reply #19 on: Sep 18, 2009, 08:39:06 pm »

Thats odd.... Why don't you try a different rss feed then and see if it still does that. I am not having that issue. My title comes up and then the url....
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=8948
Tags : RSS twitter errror Bookmark this thread : Digg Del.icio.us Dzone more....

Pages: [1] 2 Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: rss to twitter error
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 29, 2012, 01:14:47 am





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!






Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2012 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.