Phalcon url rest client - php

I have an URL HTTP with get parameter who returns a JSON object. Example :
http://example.com/params?param=X
It is possible with Phalcon to get the return of this url or I should use curl ?

So far this is not included in the Phalcon project as you can see in this answer in the official forum but you can use the incubator library files. There is some info in the forum and also you can check this link for more information.

Related

How to delete cloudinary image via PHP

I have an cloudinary_id stored in DB and want to delete this image from Cloudinary.
According documentation I call desctroy method on uploadApi with id which returns result OK. But as I see the image is still available. Dont understand it.
Tis is the code:
$cloudinary = new Cloudinary($config);
return $cloudinary->uploadApi()->destroy($file_id);
This code returns Cloudinary\Api\ApiResponse #d6b5 result => "ok"
Can somebody tell me please what is wrong with this code?
Cloudinary uses CDN to ensure fast delivery of the media resources. That being said, when deleting a media via API, you may need to pass the optional parameter "invalidation" set to true in order to invalidate that object in their CDN.
Here are their API documentation below:
https://cloudinary.com/documentation/image_upload_api_reference#destroy_method
https://cloudinary.com/documentation/admin_api#delete_resources
You may use either upload API or admin API. Both achieve the same result.
Anthony

Spotify PHP Api - {"error":"unsupported_grant_type","error_description":"grant_type parameter is missing"}. Tried everything

EDIT
I found that if I edit the code to not use http_build_query($parameters);
to convert array of parameters into the url-string, but pass the strings directly to the url it works. So how is http_build_query destroying the grant_type= authorization_code?
ORIGINAL:
I'm using the php sdk api https://github.com/jwilsson/spotify-web-api-php
and trying to connect the user. I log in using the link
https://accounts.spotify.com/authorize?
client_id=--id--
&redirect_uri=https%3A%2F%2Fwww.testsite.com%2Fspotify_connect%2F
&response_type=code
&scope=user-read-email
and get a code in return and I've traced the code towards the curl in Request->send()
the full link is
https://accounts.spotify.com/api/token?
client_id=--client--&
code=--returned_code--
&grant_type=authorization_code
&redirect_uri=https%3A%2F%2Fwww.testsite.com%2Fspotify_connect%2F
&client_secret=--secret--
I get this in return:
{"error":"unsupported_grant_type","error_description":"grant_type parameter is missing"}
I've tried sending the authorization in the header as well. Same result
Authorization: Basic base64_encode(--clientid--:--clientsecret--);
What am I doing wrong?
Using the
https://accounts.spotify.com/api/token?grant_type=client_credentials
is working like a charm, but using the code I get in return does not work.
Thanks for help :)

Updating documents with the help of cas in couchbase 2.0 server using PHP API

I am trying to update a document in Couchbase 2.0 server using PHP API (php-ext-couchbase).
http://www.couchbase.com/docs/couchbase-sdk-php-1.1/api-reference-summary.html
The document is similar to facebook POSTS with comments and likes associated with it.
To be more specific.
-Load the doc.
-Modify it
-Store the modified doc if it has not been accessed by any other person.
Basic operations that would be required to accomplish this will be
# Get a document by key
doc = get(key)
# Modify a document when no one has modified it since my last read
casVersion = doc.getCas()
cas(key, casVersion, changedDoc)
I just want to know how i can accomplish this in PHP.
especially how to get the casVersion or the revision_id of the document and then further carry out the update process so that changes made by simultaneous updates on same document are not lost.
No worries I found it,
The code is
$bucket='yourbucketname';
$cb=new Couchbase("127.0.0.1:8091","root","password",$bucket);
$old_doc=null;
$cb->getDelayed($obj_id, true,
function($cb, $data) use (&$old_doc) { $old_doc = $data; });
$casKey=$old_doc['cas'];
Use getDelayed method, and callback function to get the array having (key,value,caskey)
I hope the couchbase documentation would be more clear in future with usages examples.

Using API to get Covers - URL Error

I need some album covers for my PHP website but something is not working anymore.
I was using a JSON to get Album ID and then i was using this id to get the album cover.
My problem is that i try to decode a json from website but i don't get any result anymore (it was working before ...).
Here is the code (getting JSON and decoding it) :
$req="http://api-v3.deezer.com/1.0/search/track/?q=".$deezer."&index=0&nb_items=8&output=json";
$result = file_get_contents($req);
$testjson=json_decode($result,true);
I think you are using an old code of Deezer api (1.0 and I don't get any JSON from your url).
Try to change $req by :
$req="http://api.deezer.com/2.0/search/album/?q".$deezer."&index=0&nb_items=8&output=json";
Then, some code are missing and are important to change too.
When you try to get your image, don't forget to change the url too with that version (2.0).
You can find more information on Deezer Api : here.

Call to undefined method in facebook call to publishUserAction

I'm getting the following using the PHP client on my server (connecting via FBML). I've included the appropriate php files (facebook etc..)
Fatal error:
Call to undefined method FacebookRestClient::feed_publishUserAction()
in ..../index.php on line 50
I'm trying to use the example given.
Any ideas?
You might want to take a quick browse/grep through your Facebook API files (facebookapi_php5_restlib.php) and make sure that the feed_publishUserAction() method exists. Perhaps you're using an older version of the API library?
OMG I found the answer
Because the facebookapi_php5_restlib.php that facebook.com provided you is a piece of outdated shit
i.e. you won't be able to find the word feed_publishUserAction in the facebookapi_php5_restlib.php file
HOWEVER, the official facebook smiley demo from this facebook wiki page , contained a more completed facebookapi_php5_restlib.php , along with the feed_publishUserAction function
Which finger would you like to show to the facebook developer staffs?

Categories