Registration with profile picture using services in Drupal - drupal-7

I've been trying to upload a user profile picture during the user registration using Service 3 and so far I haven't had any luck. I tested passing a hard coded fid in the field "picture" and also tried to pass the fields "filemime", "filename", etc. and it didn't work neither.
Any idea about what fields I need to populate?
I guess it must be related to this post Using Drupal Services and DIOS SDK for setting user picture in iOS app
but it doesn't have and answer neither.

I use following code -
//Picture is first uploaded from ios using file service and fid is passed in $data object
$file_contents_object = file_load($data->picture_fid);
$file_contents_array['fid'] = $file_contents_object->fid;
$file_contents_array['uid'] = $file_contents_object->uid;
$file_contents_array['filename'] = $file_contents_object->filename;
$file_contents_array['uri'] = $file_contents_object->uri;
$file_contents_array['filemime'] = $file_contents_object->filemime;
$file_contents_array['filesize'] = $file_contents_object->filesize;
$file_contents_array['status'] = $file_contents_object->status;
$file_contents_array['timestamp'] = $file_contents_object->timestamp;
$file_contents_array['rdf_mapping'] = $file_contents_object->rdf_mapping;
//use your cck field here
$user_obj->field_user_profile_picture['und'][0] = $file_contents_array;
Hope this will help.

Related

Google Places API Autocomplete Not Showing Results

In my React application. I'm using the Google Places API Autocomplete so users will be able to type their location and their city/state/country info will be automatically filled in, but I'm getting a problem I can't solve.
const autocomplete = new google.maps.places.Autocomplete(input);
When I don't specify options to the second parameter. Everything works good but I only want to return the user's city, state, and country but when I specify a type. The autocomplete don't even show me results.
I hope that there could be something wrong when declaring your option object. But I can't exactly say without having a look at your code.
But this is the example provided by google in their google Maps Api. I hope that this will solve your problem.
var defaultBounds = new google.maps.LatLngBounds(
new google.maps.LatLng(-33.8902, 151.1759),
new google.maps.LatLng(-33.8474, 151.2631));
var input = document.getElementById('searchTextField');
var options = {
types: ['(cities)'],
componentRestrictions: {country: 'fr'} // show only results for country France
};
autocomplete = new google.maps.places.Autocomplete(input, options);
For more details you can refer google maps API
https://developers.google.com/maps/documentation/javascript/places-autocomplete

get youtube single video data api and json decode in cakephp 1.3

Ever since Google changed YouTube to API3.0 I can't fetch videos anymore. I can't get video id and api key to apiURL
$video_id = // I stript it from url
$apiKey = Configure::read('YouTube.v3.0.privateKey'); // hidden in bootstrap
$apiURL = 'https://www.googleapis.com/youtube/v3/videos?id=$video_id&key=$apiKey';
and on debug($apiURL); I'm getting
https://www.googleapis.com/youtube/v3/videos?id=$video_id&key=$apiKey
anyone can help? Thanks in Advance.
if you want little snippet, here we go, it works for me on cakephp1.3 application
$apiURL = file_get_contents("https://www.googleapis.com/youtube/v3/videos?part=snippet&id={$video_id}&key={$apiKey}");
$youtubeResponse = json_decode($apiURL, true);
$youtube_data = $youtubeResponse['items'];
// debug($youtube_data);
$youtube_data_title = $youtube_data['0']['snippet']['title'];
$youtube_data_description = $youtube_data['0']['snippet']['description'];
$youtube_data_thumbnail = $youtube_data['0']['snippet']['thumbnails']['default']['url'];
$this->set('youtube_data_title', $youtube_data_title);
$this->set('youtube_data_description', $youtube_data_description);
$this->set('youtube_data_thumbnail', $youtube_data_thumbnail);
PHP does not evaluate variables in single quotes. Your URL should be places in double quotes:
$apiURL = "https://www.googleapis.com/youtube/v3/videos?id=$video_id&key=$apiKey";
to get variables replaced with values.
Here is good read about outputing text in PHP

Python 2.7 and blobkeys: how to return the filename instead of the url?

Very new to Python/Google App Engine and just trying to work my way around a pretty massive application. This is what I currently have:
file_keys = self.request.get_all('blobKey').filename
file_links = []
for key in file_keys:
file_links.append('https://www.mysite.com/admin/downloads/%s' % key)
This will return something similar to this:
https://www.mysite.com/admin/downloads/4NLNpXrzZ0vjOZcOPzZpiQVoASeSXlZukbq0AMyFlmGYDhNZrWaRASBxL8TC6gjw
How would I go about returning just the file name? (It's a form where you enter some information and provide a file, and I would like to return that specific file's filename in the email sent out instead of the generated URL).
I would think filename would work as shown here: https://developers.google.com/appengine/docs/python/blobstore/blobinfoclass
But have not had any luck with that.
Any input is appreciated.
This is the solution I came up with:
file_keys = self.request.get_all('blobKey')
blob_info_list = blobstore.BlobInfo.get(file_keys)
file_info_list = []
for blob in blob_info_list:
info = {"file_name":blob.filename, "key":blob.key()}
file_info_list.append(info)
template_dict = { 'file_info_list':file_info_list}

tweetsharp implementation in mvc.net

Hi
I want to use Tweetsharp in my mvc.net application to get the list offriends and to share image with them.
But i haven't got the proper documentation and sample for the same. What is need to add in controller action and what in view page.
Please give some links for the same.
Thanks
munish
public void MyMethod() {
TwitterService service = new TwitterService(key, secret, "Token", "Secret");
ListFriendsOptions options = new ListFriendsOptions();
options.Cursor = 12345;
// should the response have user entities
options.IncludeUserEntities = false;
// The screen name of the user for whom to return results for.
options.ScreenName = "";
options.SkipStatus = false;
// The ID of the user for whom to return results for.
options.UserId = 12345;
// this will return a list of friends for the specified user.
TwitterCursorList<TwitterUser> listOfFriends = service.ListFriends(options);
}
Also note the code above uses a third party library called TweetSharp.
As for the images im not sure as to what to do but you can look at the twitter REST API v1.1 for information
https://dev.twitter.com/docs/api/1.1/get/friends/list
https://dev.twitter.com/docs/api/1.1
TweetSharp
https://github.com/danielcrenna/tweetsharp
I don't know about Tweetsharp but take a look at linq2twitter. It provides easy access to the Twitter API through the use of LINQ.

How can I upload a file to a Sharepoint Document Library using Silverlight and client web-services?

Most of the solutions I've come across for Sharepoint doc library uploads use the HTTP "PUT" method, but I'm having trouble finding a way to do this in Silverlight because it has restrictions on the HTTP Methods. I visited this http://msdn.microsoft.com/en-us/library/dd920295(VS.95).aspx to see how to allow PUT in my code, but I can't find how that helps you use an HTTP "PUT".
I am using client web-services, so that limits some of the Sharepoint functions available.
That leaves me with these questions:
Can I do an http PUT in Silverlight?
If I can't or there is another better way to upload a file, what is it?
Thanks
Figured it out!! works like a charm
public void UploadFile(String fileName, byte[] file)
{
// format the destination URL
string[] destinationUrls = {"http://qa.sp.dca/sites/silverlight/Answers/"+fileName};
// fill out the metadata
// remark: don't set the Name field, because this is the name of the document
SharepointCopy.FieldInformation titleInformation = new SharepointCopy.FieldInformation
{DisplayName =fileName,
InternalName =fileName,
Type = SharepointCopy.FieldType.Text,
Value =fileName};
// to specify the content type
SharepointCopy.FieldInformation ctInformation = new SharepointCopy.FieldInformation
{DisplayName ="XML Answer Doc",
InternalName ="ContentType",
Type = SharepointCopy.
FieldType.Text,
Value ="xml"};
SharepointCopy.FieldInformation[] metadata = { titleInformation };
// initialize the web service
SharepointCopy.CopySoapClient copyws = new SharepointCopy.CopySoapClient();
// execute the CopyIntoItems method
copyws.CopyIntoItemsCompleted += copyws_CopyIntoItemsCompleted;
copyws.CopyIntoItemsAsync("http://null", destinationUrls, metadata, file);
}
Many Thanks to Karine Bosch for the solution here: http://social.msdn.microsoft.com/Forums/en/sharepointdevelopment/thread/f135aaa2-3345-483f-ade4-e4fd597d50d4
What type of SharePoint deployment and what version of silverlight? If say it is an intranet deployment you could use UNC paths to access your document library in sharepoint and the savefiledialog/openfiledialog available in Silverlight 3.
http://progproblems.blogspot.com/2009/11/saveread-file-from-silverlight-30-in.html
or
http://www.kirupa.com/blend_silverlight/saving_file_locally_pg1.htm
Silverlight has restrictions on what it can do with local files, though I've read that silverlight 4 has some changes.
http://www.wintellect.com/CS/blogs/jprosise/archive/2009/12/16/silverlight-4-s-new-local-file-system-support.aspx

Resources