A
A
Alexey2015-12-16 15:23:18
PHP
Alexey, 2015-12-16 15:23:18

How to save an avatar through the Odnoklassniki API authorization?

Hello! I still can’t finish authorization through social networks (there are finishing touches).
When authorizing through VKontakte, a link to the picture is given directly, but how to save the avatar, the link to which was received in this form (I changed all the codes, so the link will not work):

https://usd1.mycdn.me/image?id=287740762359&bid=124533263729&t=2&plc=API&viewToken=LSb1RF3nsdfgJHgjGgjwTe6Q&tkn=*VoSJHGGjgjhGS1tqUy-MEsKJKfhkbrqM

I tried via cURL like this:
$ch = curl_init($userInfo['pic_2']);  
  curl_setopt($ch, CURLOPT_HEADER, 0);  
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  
  curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);  
  $out = curl_exec($ch);  
  $image_sv = $_SERVER['DOCUMENT_ROOT'].'/uploads/pic_2.jpg';  
  $img_sc = file_put_contents($image_sv, $out);  
  curl_close($ch);

But here's the end result:
1b0bc7816ed8424195b2e336be993f61.jpg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey, 2015-12-16
@dzheka3d

Sori got it! It was https changed to http and voila))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question