VK video API in PHP - php

I would like an API in PHP for the direct link to download videos from social network VK.
Example:
(VK video link)
$source = 'https://vk.com/video-51189706_456246056';
(Through the source, generate direct links to all available video qualities)
$720p = 'https://psv49-7.daxab.com/cs1-67v4.vkuservideo.net/p18/8835b7e86c59.720.mp4';
$480p = 'https://psv49-7.daxab.com/cs1-67v4.vkuservideo.net/p18/8835b7e86c59.720.mp4';
Is it possible in PHP?

Assuming you have an access token, all you have to do is to perform a POST request at video.get method.
I am not familiar with PHP, but here is the simplest curl representation.
curl -X POST \
-d 'v=5.92' \
-d 'access_token=%YOUR_ACCESS_TOKEN%' \
-d 'videos=-51189706_456246056' \
https://api.vk.com/method/video.get

Related

How to upload file in dropbox using php or curl [duplicate]

I am searching everywhere and haven't been able to locate a suitable example and am not well versed enough to be able to sort it out via the docs. Could someone with more knowledge than I show me how to form the CURL command for OAUTH 2? And is it that I only need the OAUTH 2 secret key? I am being shown an App key, app secret and oauth 2. I am using this in a perl script if it matters.
The closest code I have found is this:
curl --request PUT --header "Content-Length: `ls -la jonathan.txt | awk '{ print $5}'`" --header
"Content-Type: multipart/mixed" --data-binary "#jonathan.txt" "https://api-
content.dropbox.com/1/files_put/dropbox/jonathan.txt?access_token=ABCDEF"
But I don't think that is OAUTH 2?
If you have an access token (created via the app console):
curl -H "Authorization: Bearer <your token>" https://api-content.dropbox.com/1/files_put/auto/ -T <your file path>
You need an access token for the account. (This is typically acquired by going through the OAuth flow, but you can also get one for your own account by clicking the "Generate" button on the page for your Dropbox app. See https://www.dropbox.com/developers/blog/94/generate-an-access-token-for-your-own-account.)
Once you have an access token, your curl command should probably work, though I prefer --header "Authorization:Bearer abc123xyz" over putting the access token in a query parameter. Also, drop the Content-Type: multipart/mixed, since that's not what you're sending.
I'd also recommend "auto" instead of "dropbox," just because it always does the right thing regardless of the app type.
Here is working codes to upload file in dropbox via CURL request.
curl -X POST https://content.dropboxapi.com/2/files/upload \
--header "Authorization: Bearer <your token>" \
--header "Dropbox-API-Arg: {\"path\": \"/file_path.txt\",\"mode\": \"add\",\"autorename\": true,\"mute\": false}" \
--header "Content-Type: application/octet-stream" \
--data-binary "#file_path.txt"

PHP and CURL multipart/related

I'm trying to take a picture with a smartphone and send it to a OCR-Server.
I'm now having problem to post the picture with php to the Open-OCR server
Open-OCR provides a sample file howto upload local files to the server.
https://github.com/tleyden/open-ocr/blob/master/docs/upload-local-file.sh
The bash curl command that will be generated looks like this.
curl -v -X POST http://192.168.0.107:9292/ocr-file-upload --header 'Content-Type: multipart/related; boundary="2ac80ee2f500dbe0bae6d3148fe4f960"' --data-binary #-
How can I convert this command to PHP?
I'm really a noob in WEB-Dev and would really appreciate a sample php code that will imitate that command.

Preparing CURL request with php

I would like to have the following curl request generated using php CURL library for webdav.
curl -n -X MOVE "http://localhost/ocm/remote.php/webdav/dir1/subdir" -H "Destination: http://localhost/ocm/remote.php/webdav/dir1/"
Please help
Go through this..It shows all the curl option available to use in PHP along with examples...

Manage Facebook profiles using API

I have a php application.I want to manage my facebook profile from my application itself.
1)Logged in to facebook
2)Add comments
3)update my profile
etc.....
is it possible using facebook API.
Help is highly appreciated.
Thanks,
Companion
Yes it is possible. Have a look at this description of the Facebook Graph API, near the bottom is a section on publishing (you do it by sending POST request...):
http://developers.facebook.com/docs/api/
And here is their example for posting to someones wall:
curl -F 'access_token=...' \
-F 'message=Hello, Arjun. I like this new API.' \
https://graph.facebook.com/arjun/feed
And here is an exmaple of posting something to your own feed:
curl -F 'access_token=...' \
-F 'message=I am posting to my own feed. I am awesome.' \
https://graph.facebook.com/me/feed

cURL command to NSURLRequest

I want to convert cURL command:
curl -F 'access=xxxx' \
-F 'message=Hello.' \
-F 'picture=#1.jpg' \
https://example.com
to a NSURLRequest.
Can somebody please help me with this?
If you want to create a request with POST data, I suggest you to use ASIHTTPRequest: http://allseeing-i.com/ASIHTTPRequest
It is quite powerful and easy to use, you should take a look at the ASIFormDataRequest class (see the How To Use section).
I've never used it for SSL connections though, but I'm pretty sure it's possible.

Categories