Laravel Socialite HTTPS twitter avatar - php

I am using laravel 5.0 and utlising the socialite extension to enable twitter login. I encountered a problem with the retrieval of the users twitter profile picture.
The url for the profile picture I receive from twitter is in the following format.
http://pbs.twimg.com/profile_images/662983942727999489/q5I9DMyE_normal.png
This is saved to my db and shown when the user logs into their account. The problem is this image is serving over HTTP and is producing browser warnings when users are accessing their account, as not all the page content is served over HTTPS.
Is there any way to save the twitter profile picture with HTTPS compared to HTTP.
$user = User::create([
'provider_id' => $userData->id,
'name' => $userData->name,
'username' => $userData->nickname,
'email' => $userData->email,
'avatar' => $userData->avatar,
'active' => 1,
]);
I save the user twitter data to my db as shown above and it the $userData->avatar part which is saving the HTTP url.
I can't seem to work a way around this and can't find much documentation on the issue. Any help would be appreciated.

Well, verifying this url, it seems simple https:// for the same url works, so you can do:
$user = User::create([
'provider_id' => $userData->id,
'name' => $userData->name,
'username' => $userData->nickname,
'email' => $userData->email,
'avatar' => str_replace('http://','https://',$userData->avatar),
'active' => 1,
]);

Related

Sharing file in team drive publicly

I've been trying to set permissions of a file I upload through code to a shared drive through a service account so that the file is publicly visible, unfortunately everything I've tried thus far doesn't seem to be working. Uploading the file to the shared drive works correctly, but making it publicly accessible does not. I create my permission like this below. Note, the below call is deferred.
$permissions = new Google_Service_Drive_Permission([
'type' => 'domain',
'domain' => '[DOMAIN]',
'role' => 'reader',
'allowFileDiscovery' => false,
'supportsAllDrives' => true,
'transferOwnership' => true,
'fields' => '*'
]);
$service->permissions->create($status['id'], $permissions);
$status['id'] is returned after all the file chunks are uploaded, and I've printed it to make sure that it is the correct file id. The service account uploads the file, so it should have permission to update these permissions, but it doesn't seem to be working. If it matters, the service account is a contributor on the shared drive. Any guidance would be appreciated, and I can further update my post with more of my code if needed.
It turns out I was putting the parameters in the wrong spot. In order to get what I wanted I used this
$params = [
'supportsAllDrives' => true
];
$service->permissions->create($status['id'], new Google_Service_Drive_Permission([
'role' => 'reader',
'type' => 'domain',
'domain' => '[DOMAIN]',
'allowFileDiscovery' => false
]), $params);
$service->permissions->create($status['id'], $permissions);

Download enterprise.wsdl.xml from Salesforce

I'm trying to configure this package https://github.com/davispeixoto/Laravel-5-Salesforce
in my laravel app
Expecting
return [
'username' => 'YOUR_SALESFORCE_USERNAME',
'password' => 'YOUR_SALESFORCE_PASSWORD',
'token' => 'YOUR_SALESFORCE_TOKEN',
'wsdl' => 'path/to/your/enterprise.wsdl.xml',
];
It have 3 parameters.
'username' => 'YOUR_SALESFORCE_USERNAME',
'password' => 'YOUR_SALESFORCE_PASSWORD',
'token' => 'YOUR_SALESFORCE_TOKEN',
But I'm not sure what is
`'wsdl' => 'path/to/your/enterprise.wsdl.xml',`
Where and how do I get enterprise.wsdl.xml ?
Log in to your Salesforce account. You must log in as an
administrator or as a user who has the “Modify All Data” permission.
From Setup, enter API in the Quick Find box, then select API.
Click Generate Metadata WSDL and save the XML WSDL file to your file system.
Click Generate Enterprise WSDL and save the XML WSDL file to
your file system.

facebook PHP SDK posting as activity, not post

I hope you will be able to help me.
I'm developing an app, and I'm willing to post an activity (that appears on user timeline in recent activity) everytime the user use my application.
Although, for the moment, I have this code below, and it only posts a normal link :
if($can_post){
$facebook->api('/'.$uid.'/feed', 'post', array(
'message' => '',
'name' => 'Name',
'caption' => 'Caption',
'description' => 'SDesc',
'picture' => 'picture url',
'link' => 'link',
'actions' => array(array('name' => 'catch phrase',
'link' => 'http://link'))
));
Check out this guide on posting "stories" to the user's timeline using the Open Graph API, so maybe it's this functionality that you need. The example they give is just a like, but it can be easily modified.
Be aware that Facebook will have to approve you app again if you want to use stories (see end of page on link above).
It's also worth noting that Facebook have also defined a wide range of predefined "Actions" to help in the process, so it's a good idea to check to see if your app falls into one of these categories.

Twitter's latest OAuth system conflict

I have a website..previously when I was uploading a new post in my blog..It was getting posted to twitter automatically. But since the new version of OAuth system..It no longer works...Can anybody help me to sort out what to change?
My code is :
'Twitter'=>array(
'enabled' => true, //set to false to shut off twitter integration
'username' => 'blogspott', //your twitter.com username
'password' => 'W3Sw9OpW6HvZYl', //your twitter.com pasword
'consumer_key' => 'TdQS15VHBdZNIrQ7RPqVQ',
'consumer_secret' => 'B2Xe5h3lHXVXUgoCAxgAIdJDTeBf6AywRoGiTwB7I',
'oauth_token' => '283508422-FkiIyZq2tpx1PQOyBLyWyomXY9OdMKxxSKGcg9d3',
'oauth_token_secret' => '548kxcZCvhytdRkJ405QeWONvMyXNEpSZszIMEYU4W4',
'tweet'=>'#%POST% for just %URL-TO-POST% %LINK%',
// Bit.ly / URL Shortening
// Within your Tweets, auto-append short URLs i.e., bit.ly/s8dJksm, to save on space.
// Sign up for an API account at http://bit.ly, and place the information
// for that account in the box below
'short_url'=>array(
'append_short_url'=>false,
'short_url_provider'=>'bit.ly', // current option: bit.ly only (default), more soon!
'bitly'=>array(
'login' => 'o_78ocugrkqtf',
'api_key' => 'R_734dbe3be47605c405f4e19ec35eb617'
),
)
),
I am using the right keys here..I've double checked it.
Twitter did not change its OAuth system recently. It is not concerned by the controversial Twitter API 1.1. So verify that you are doing it just like Twitter asks and that you do not use deprecated endpoints (Twitter removed some of them recently).

how to add share action to the post in facebook?

i'm using this code to post to my application wall
$attachment = array('message' => 'xxxxxxxxxxxxxxxx...',
'name' => 'xxxxxxxxxxxxxxxxxxx',
'caption' => 'xxxxxxxxxxxxxxxxxx',
'link' => 'xxxxxxxxxxxxxxxxxx',
'description' => 'xxxxxxxxxxxxxxxxxx',
'picture' => 'xxxxxxxxxxxxxxxxxx',
'actions' => array(array('name' => 'Download!',
'link' => 'xxxxxxxxxxxxxxxxxx'))
);
$result = $facebook->api('/2222222222222/feed/','post',$attachment);
when i post to my application wall manually the post is appearing on the application users wall with the share action
but when i use the above code it only appear on the app wall with like and comment actions only.
why?
and how to add the share action to the actions array?
i didn't find any answer online, but i just found the solution to my problem by chance
i removed the action parameter from the attachment.
but if there is a link parameter in the attachment the share action won't appear so you will have to give up the link parameter.
the proper names for the action link is:
array( array('text' => 'Download!', 'href' => 'xxxxxxxxxxxxxxx'));
Keep in mind that you can't use action links in the graph api (yet). so this functionality is limited to the REST api.
Let me know if this helps
http://facebookanswers.co.uk/?p=270
This article explains it. The key is this:
'actions' => array('name'=>'Sweet FA','link'=>'http://www.facebookanswers.co.uk'),
This is fine for adding one action. However, I'm not sure how to add two.
Hi the solution is here
instead of
$result = $facebook->api('/2222222222222/feed/','post',$attachment);
use
$result = $facebook->api('/2222222222222/links/','post',$attachment);
i'm still facing one little problem with the picture not showing after this change, if i come to a solution to it I'll come back here and post it.

Categories