API Twitter 1.1 account/update_profile_image - api

I do not know at all how to get the avatar of the profile of a twitter account: /
Even looking at the DOC here:
https://dev.twitter.com/rest/reference/post/account/update_profile_image
If a kind person could help me.
Here is my code without the class
if(isset($_GET['name']))
{
$name= htmlentities($_GET['name']);
}
$cache = 'cache/tweets.tmp';
if(time() - filemtime($cache) > 60){
require 'class/twitteroauth.php';
$connection = new TwitterOAuth('***','****', '**-**', '****');
$pics = $connection->post('account/update_profile_image','//screen_name => HERE...$name....');
//var_dump($pics);
file_put_contents($cache, serialize($pics));
}else{
echo 'Cache utilisé';
$pics = unserialize(file_get_contents($cache));
}

You're looking at the documentation for updating a Twitter user's profile image. From your question, I take it that you simply want to get this image. Remember a POST request is meant for creating new content, not simply GETting it.
Have a look at this:
https://dev.twitter.com/rest/reference/get/users/show
The users/show method provides various information about the user, including a link to the image with the key profile_image_url.
This answer should provide more detail to help you figure it out.

Related

Brach URL is giving "Trouble creating a URL" when tracking is disabled and trying to create a short url

For GDPR compliance reasons, we have disabled link tracking in our Android and iOS applications and using generate Short URL method for getting the short link of the item, we want to share. But when we are calling generateShortUrl() method, it gives "Trouble creating a URL. Tracking is disabled. Requested operation cannot be completed when tracking is disabled" error and the URL that is returned does not work when shared on Facebook or an email when the user clicks on it.
Our concern is though tracking is disabled and Branch is unable to create a short URL, it shall return the working long URL at least. Please let us know if we have to do something here to make it work on our apps.
Can you please check if you set generateShortUrl like the following example codes for Android? You can also find detailed information about creating deep link
Android : https://docs.branch.io/apps/android/#create-deep-link
iOS : https://docs.branch.io/apps/ios/#create-deep-link
.
import io.branch.indexing.BranchUniversalObject;
import io.branch.referral.Branch;
import io.branch.referral.BranchError;
import io.branch.referral.util.LinkProperties;
BranchUniversalObject buo = new BranchUniversalObject();
LinkProperties lp = new LinkProperties();
buo.generateShortUrl(this, lp, new Branch.BranchLinkCreateListener() {
#Override
public void onLinkCreate(String url, BranchError error) {
if (error == null) {
Log.i("BRANCH SDK", "got my Branch link to share: " + url);
}
}
});
Also, if you have any further questions, please contact support#branch.io to give better assistance.

How to configure ZK form to show browser cache data?

I am new to ZK framework. As per my requirement, I need to convert JSP-Servlet based application into ZK framework. One requirement is I need to show previously filled data [stored in browser cache] in forms input boxes when user click in that input box or type similar characters.
This was the default behavior in the JSP-Servlet application or any other HTML based GUI. But by default ZK form does not show previously filled data. I tried some googling to find its solution but could not found any. Please provide me the solution for that.
Thanks in advance :)
You can use cookies for that.
Here is a link to the documentation of cookies for zk.
Code provided in the link :
public void onCookie(){
try {
//add cookie
HttpServletResponse response = (HttpServletResponse)Executions.getCurrent().getNativeResponse();
Cookie userCookie = new Cookie("user", "xxx123");
response.addCookie(userCookie);
//get cookie
Cookie [] cookies = ((HttpServletRequest)Executions.getCurrent().getNativeRequest()).getCookies();
System.out.println(cookies[0].getName());
} catch (Exception e) {
e.printStackTrace();
}
}

Attach photo to Activity through Google + Domains API

Im trying to post an activity with an image to a google+ domain with the new google + domains API
Posting an activity is working fine but when i try to attach a photo to it, i receive a 500 error with null description.
This is the code:
String msg = "Activity with photo";
// Create a list of ACL entries
PlusAclentryResource resource = new PlusAclentryResource();
resource.setType("domain"); // Share to domain
List<PlusAclentryResource> aclEntries = new ArrayList<PlusAclentryResource>();
aclEntries.add(resource);
Acl acl = new Acl();
acl.setItems(aclEntries);
acl.setDomainRestricted(true); // Required, this does the domain restriction
// Create a new activity object
Activity activity = new Activity()
.setObject(new Activity.PlusObject().setOriginalContent(msg))
.setAccess(acl);
// Attach the link
Activity.PlusObject.Attachments attachment = new Activity.PlusObject.Attachments();
attachment.setObjectType("photo");
attachment.setUrl( "http://c299813.r13.cf1.rackcdn.com/MuseeduLouvre_1335428699_org.jpg" );
attachment.setId( randomId ); //if not specified, google returns an error with "you must specify the photo id"
List<Activity.PlusObject.Attachments> attachments = new ArrayList();
attachments.add(attachment); // You can also add multiple attachments to the post
activity.getObject().setAttachments(attachments);
activity = plus.activities().insert("me", activity).execute();
When the code calls the execute, i receive this error:
com.google.api.client.googleapis.json.GoogleJsonResponseException: 500
{
"code": 500,
"message": null
}
at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:145)
The same code but with the attachemnt lines commented works fine. Has someone managed to create an activity with an image? any clue?
Thanks in advance.
Directly attaching a photo via URL isn't possible. The process works slightly differently, as described here: https://developers.google.com/+/domains/posts/attaching-media
If you don't have the actual binary data of the photo you will first have to "download" the photo. Then you can upload the actual photo data via the media().insert method, which will give you the Photo Id which you can then use in attachment.setId().
setUrl isn't necessary in this case.
If you want to attach a photo as URL, this could also be handled like an article attachment (same as if you would just copy/paste the URL into a Google+ post). In that case you would use attachment.setObjectType("article") and only set the Url. The id isn't necessary in this case.

Posting canvas image to user's wall via facebook javascript sdk

I have dynamically created a html canvas image. I want to post it to facebook user's wall via javascript sdk. What I am doing is
I tried to convert canvas into a javascript image object & provide finalimage in fb.ui method
var temp = canvas.toDataURL("image/png");
var finalimage=temp.replace(/^data:image\/(png|jpg);base64,/, "");
FB.ui(
{
method: 'feed',
name: 'The Facebook SDK for Javascript',
caption: 'Bringing Facebook to the desktop and mobile web',
description: (
'A small JavaScript library that allows you to harness ' +
'the power of Facebook, bringing the user\'s identity, ' +
'social graph and distribution power to your site.'
),
link: 'https://developers.facebook.com/docs/reference/javascript/',
picture: finalimage
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);
But I am getting an error
Error Message: picture URL is not properly formatted
Can anyone please help how do I do that??
You need to save the image at your server for doing that, your image must be outside Facebook, because FB.ui "FEED" does not accept base64 encoded data as picture, its impossible .
Its very large data, and if you try to short the base64 code into a url shorteer, you will find difficulties too .
What you can do, and what i am doing, is use an PHP server to get the Base64 data, and convert it into image, like a dynamic image, ok? But a memory problem will be created .
Another option is (really) posting the canvas as an image on user profile, so you will need use FB.api for that, instead of FB.ui, feed dialog is used for sharing links, and, canvas doesnt have Title, Description, proprieties .
After posting the image, you will get an response, with ID, that is post ID, and this cannot be used on Feed as Link or Image proprietity, but you can use Share Dialog, if you want to share the post .
That is piece of cake, i done that, and recommend you do the same .
Posting Canvas as images usin API on Facebook Platform is great, you can do that using JavaScript SDK .

Captcha image and raw format

I've trying to get properly work kcaptcha class from kcaptcha.ru in my own component. 'Cause class not build for Joomla natively I break my brain on the wall.
And at the beginning...
I've a url to image generated by this class like: http://.../index.php&task=captcha&format=raw
In main controller I've put method
function captcha() {
include(JPATH_COMPONENT.DS.'libraries'.DS.'captcha'.DS.'kcaptcha'.DS.'kcaptcha.php');
$session = &JSession::getInstance('default', array());
$captcha = new KCAPTCHA();
if ($session) {
$session->set('captcha_keystring', $captcha->getKeyString());
}
}
And I've see in browser
When I request an image from the class all working good but in my component I cannot set session variables.
Any ideas how to fix this problem?
And problem solved successfully.
For &format=raw in controller Joomla set default mime-type to text/html.
For healing this issue developer must reset mime/type via setting
$document = &JFactory::getDocument();
$document->setMimeEncoding('image/png');
mime/encoding off course depends on you needs.