Recent Topics

1 Sep 28, 2011 10:52    

Hello
i have a problem to upload pictures with a blog client (Ecto) or iblogger on Iphone.
with ecto, i have got error 1015 and with iblogger, this kind of link instead the picture /var/mobile/Applications/01938D51-1CEE-4A2F-8DE3-1B81DE55260D/Documents/ImageCache/1912496029.jpg

Thanks for your help

2 Sep 29, 2011 10:24

Solve it : it was a problem with metaweblog API
i copied lines from old version of the API to restore the possibility of uploading files

3 Sep 30, 2011 07:32

Are you talking about a problem in b2evolution or in the client software you use?

4 Sep 30, 2011 09:23

it was a problem with metaweblog API
i copied code from an old API and now, it's work

I had the same problem to get category name.

5 Sep 30, 2011 18:52

That's what I'm asking about. Did you change code in b2evolution /inc/xmlrp/api/_metaweblog.api.php ?
If you did, what older version you copied it from?

6 Oct 01, 2011 11:23

Yes i changed it: I implement an old code part from version 2.4
but I'm not able to recover categories names...

7 Oct 01, 2011 16:10

I will check this.. moved to the "bugs" section

8 Oct 03, 2011 14:05

I implemented code from old version (2.4) for category and Files download

for media

function mw_newmediaobject($m)
{
	global $xmlrpcerruser; // import user errcode value
	global $Settings, $baseurl,$fileupload_allowedtypes;

	// CHECK LOGIN:
  /**
	 * @var User
	 */
	if( ! $current_User = & xmlrpcs_login( $m, 1, 2 ) )
	{	// Login failed, return (last) error:
		return xmlrpcs_resperror();
	}

	// GET BLOG:
  /**
	 * @var Blog
	 */
	if( ! $Blog = & xmlrpcs_get_Blog( $m, 0 ) )
	{	// Login failed, return (last) error:
		return xmlrpcs_resperror();
	}

	// CHECK PERMISSION:
	// For lack of more subtle perm: require any edit perm on blog + global file add perm.
	if( ! $current_User->check_perm( 'blog_post_statuses', 'edit', false, $Blog->ID )
		|| ! $current_User->check_perm( 'files', 'add', false ) )
	{	// Permission denied
		return xmlrpcs_resperror( 3 );	// User error 3
	}
	logIO( 'Permission granted.' );


	if( ! $Settings->get('upload_enabled') )
	{
		return new xmlrpcresp(0, $xmlrpcerruser+2, // user error 2
				 'Object upload not allowed ');
	}


	$xcontent = $m->getParam(3);


	// Get the main data - and decode it properly for the image - sorry, binary object
	$contentstruct = xmlrpc_decode_recurse($xcontent);

	$data = $contentstruct['bits'];

	$type = $contentstruct['type'];
	logIO( 'Received MIME type: '.$type );

	$rf_filepath = $contentstruct['name'];
	logIO( 'Received filepath: '.$rf_filepath );
	// Avoid problems:
	$rf_filepath = strtolower($rf_filepath);
	$rf_filepath = preg_replace( '¤[^a-z0-9\-_./]¤', '-', $rf_filepath);
	logIO( 'Sanitized filepath: '.$rf_filepath );

 	load_funcs('files/model/_file.funcs.php');

	// Split into path + name:
	$filepath_parts = explode( '/', $rf_filepath );
	$filename = array_pop( $filepath_parts );

	// Check valid filename/extension: (includes check for locked filenames)
	logIO( 'File name: '.$filename );
	if( $error_filename = validate_filename( $filename, false ) )
	{
		return new xmlrpcresp(0, $xmlrpcerruser+4, // user error 4
			'Invalid objecttype for upload ('.$filename.'): '.$error_filename);
	}

	// Check valid path parts:
	$rds_subpath = '';
	foreach( $filepath_parts as $filepath_part )
	{
		if( empty($filepath_part) || $filepath_part == '.' )
		{	// self ref not useful
			continue;
		}

		if( $error = validate_dirname($filepath_part) )
		{ // invalid relative path:
			logIO( $error );
			return new xmlrpcresp(0, $xmlrpcerruser+3, // user error 3
				$error );
		}

		$rds_subpath .= $filepath_part.'/';
	}
	logIO( 'Subpath: '.$rds_subpath );

	$fileupload_path = $Blog->get_media_dir();
	if( ! $fileupload_path )
	{
		return new xmlrpcresp(0, $xmlrpcerruser+5, // user error 5
			'Error accessing Blog media directory.');
	}

	// Create subdirs, if necessary:
	if( !empty($rds_subpath) )
	{
		$fileupload_path = $fileupload_path.$rds_subpath;
		if( ! mkdir_r( $fileupload_path ) )
		{	// Dir didn't already exist and could not be created
			return new xmlrpcresp(0, $xmlrpcerruser+6, // user error 6
				'Error creating sub directories: '.rel_path_to_base($fileupload_path));
		}
	}

	$afs_filepath = $fileupload_path.$filename;
	logIO( 'Saving to: '.$afs_filepath );
	$fh = @fopen( $afs_filepath, 'wb' );
	if( !$fh )
	{
		logIO( 'Error opening file' );
		return new xmlrpcresp(0, $xmlrpcerruser+7, // user error 7
			'Error opening file for writing.');
	}

	$ok = @fwrite($fh, $data);
	@fclose($fh);

	if (!$ok)
	{
		logIO( 'Error writing to file' );
		return new xmlrpcresp(0, $xmlrpcerruser+8, // user error 8
			'Error while writing to file.');
	}

	// chmod uploaded file:
	$chmod = $Settings->get('fm_default_chmod_file');
	logIO( 'chmod to: '.$chmod );
	@chmod( $afs_filepath, octdec( $chmod ) );

	$url = $Blog->get_media_url().$rds_subpath.$filename;
	logIO( 'URL of new file: '.$url );


	// - return URL as XML
	$urlstruct = new xmlrpcval(array(
			'url' => new xmlrpcval($url, 'string')
		), 'struct');

	logIO( 'OK.' );
	return new xmlrpcresp($urlstruct);
}

9 Oct 03, 2011 14:06

function mw_getcategories( $m )
{
	global $DB;
	// CHECK LOGIN:
  /**
	 * @var User
	 */
	if( ! $current_User = & xmlrpcs_login( $m, 1, 2 ) )
	{	// Login failed, return (last) error:
		return xmlrpcs_resperror();
	}

	// GET BLOG:
  /**
	 * @var Blog
	 */
	if( ! $Blog = & xmlrpcs_get_Blog( $m, 0 ) )
	{	// Login failed, return (last) error:
		return xmlrpcs_resperror();
	}

	// CHECK PERMISSION: (we need at least one post/edit status)
	if( ! $current_User->check_perm( 'blog_post_statuses', 1, false, $Blog->ID ) )
	{	// Permission denied
		return xmlrpcs_resperror( 3 );	// User error 3
	}
	logIO( 'Permission granted.' );


	$sql = "SELECT cat_ID, cat_name
					FROM T_categories ";

	$aggregate_coll_IDs = $Blog->get_setting('aggregate_coll_IDs');
	if( empty( $aggregate_coll_IDs ) )
	{	// We only want posts from the current blog:
		$sql .= 'WHERE cat_blog_ID ='.$Blog->ID;
	}
	else
	{	// We are aggregating posts from several blogs:
		$sql .= 'WHERE cat_blog_ID IN ('.$aggregate_coll_IDs.')';
	}

	$sql .= " ORDER BY cat_name ASC";
	$rows = $DB->get_results( $sql );
	if( $DB->error )
	{	// DB error
		return new xmlrpcresp(0, $xmlrpcerruser+9, 'DB error: '.$DB->last_error ); // user error 9
	}
	xmlrpc_debugmsg( 'Categories:'.count($rows) );

	$ChapterCache = & get_Cache('ChapterCache');
	$data = array();
	foreach( $rows as $row )
	{
		$Chapter = & $ChapterCache->get_by_ID($row->cat_ID);
		if( ! $Chapter )
		{
			continue;
		}
		$data[] = new xmlrpcval( array(
				'categoryId' => new xmlrpcval( $row->cat_ID ), // not in RFC (http://www.xmlrpc.com/metaWeblogApi)
				'description' => new xmlrpcval( $row->cat_name ),
				'categoryName' => new xmlrpcval( $row->cat_name ), // not in RFC (http://www.xmlrpc.com/metaWeblogApi)
				'htmlUrl' => new xmlrpcval( $Chapter->get_permanent_url() ),
				'rssUrl' => new xmlrpcval( url_add_param($Chapter->get_permanent_url(), 'tempskin=_rss2') )
			//	mb_convert_encoding( $row->cat_name, "utf-8", "iso-8859-1")  )
			),"struct");
	}

	logIO( 'OK.' );
	return new xmlrpcresp( new xmlrpcval($data, "array") );

}

10 Oct 04, 2011 06:23

All xmlrpc APIs need to be checked, they are not up to date at all. I couldn't get WP API to work.


Form is loading...